بنقرة واحدة
add-query
Add a new query to @ecency/sdk or the web app with React Query integration
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Add a new query to @ecency/sdk or the web app with React Query integration
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Add a new feature to the Ecency web app following established patterns
Add a new blockchain mutation to @ecency/sdk and wire it up in the web app
Review code changes for bugs, patterns violations, and common pitfalls in the vision-next codebase
Debug common issues in the vision-next Hive web app with known solutions and investigation patterns
| name | add-query |
| description | Add a new query to @ecency/sdk or the web app with React Query integration |
| argument-hint | ["query-name"] |
| disable-model-invocation | true |
Create a new data query with React Query integration.
| Data type | Package | Location |
|---|---|---|
| Hive blockchain data (posts, accounts, communities) | @ecency/sdk | packages/sdk/src/modules/<domain>/queries/ |
| Wallet/asset data (balances, tokens, SPK) | @ecency/wallets | packages/wallets/src/modules/ |
| App-specific data (polls, threespeak, market) | @ecency/web | apps/web/src/api/queries/ |
Location: packages/sdk/src/modules/core/query-keys.ts
static <domain> = {
_prefix: ["<domain>"] as const,
all: () => [...QueryKeys.<domain>._prefix, "all"] as const,
byId: (id: string) => [...QueryKeys.<domain>._prefix, "byId", id] as const,
list: (params: Record<string, unknown>) => [...QueryKeys.<domain>._prefix, "list", params] as const,
};
Location: packages/sdk/src/modules/<domain>/queries/get-<entity>-query-options.ts
The SDK uses query option builders (not hooks) so they work in both React and non-React contexts:
import { queryOptions } from "@tanstack/react-query";
import { QueryKeys } from "@/modules/core/query-keys";
import { CONFIG } from "@/modules/core/config-manager";
export function get<Entity>QueryOptions(param?: string) {
// Guard against undefined params
if (!param) {
return queryOptions({
queryKey: QueryKeys.<domain>.byId(""),
queryFn: () => null,
enabled: false,
});
}
return queryOptions({
queryKey: QueryKeys.<domain>.byId(param),
queryFn: async () => {
const result = await CONFIG.hiveClient.call("bridge", "<api_method>", { param });
return result;
},
enabled: !!param,
});
}
For infinite queries (paginated lists):
import { infiniteQueryOptions } from "@tanstack/react-query";
export function get<Entity>InfiniteQueryOptions(params: Params) {
return infiniteQueryOptions({
queryKey: QueryKeys.<domain>.list(params),
queryFn: async ({ pageParam }) => {
return CONFIG.hiveClient.call("bridge", "<method>", {
...params,
start_author: pageParam?.author,
start_permlink: pageParam?.permlink,
});
},
initialPageParam: undefined as PageParam | undefined,
getNextPageParam: (lastPage) => {
if (!lastPage || lastPage.length < PAGE_SIZE) return undefined;
const last = lastPage[lastPage.length - 1];
return { author: last.author, permlink: last.permlink };
},
});
}
// packages/sdk/src/modules/<domain>/index.ts
export * from "./queries/get-<entity>-query-options";
import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
import { get<Entity>QueryOptions } from "@ecency/sdk";
// In a component
function MyComponent({ id }: { id: string }) {
const { data, isLoading } = useQuery(get<Entity>QueryOptions(id));
// ...
}
// For prefetching (SSR or route loading)
await queryClient.prefetchQuery(get<Entity>QueryOptions(id));
pnpm --filter @ecency/sdk build
pnpm --filter @ecency/sdk test
enabled flag prevents automatic fetches but NOT direct queryClient.fetchQuery() calls. Always add a falsy guard that returns { enabled: false, queryFn: () => null } when required params are missing.getXQueryOptions() functions, not useX() hooks. This keeps them usable for SSR prefetching and non-React contexts.pnpm --filter @ecency/sdk buildfilterDmcaEntry utility for post queries to filter flagged contentCONFIG.hiveClient handles node failover automatically. Don't cache the client address — it may change during a request.