A TypedDocumentNode for the query (e.g. from codegen or a gql template).
Optionalvariables: V["input"]Optional initial variables (the input value). Automatically wrapped as { input: variables } before sending. The query fires when this is set and again whenever it changes (compared by value); omit it for a manually triggered query.
Optionaloptions: LazyQueryHookOptions<T, V>Optional Apollo LazyQueryHookOptions (e.g. fetchPolicy, notifyOnNetworkStatusChange). Merged into the underlying useLazyQuery.
Tuple: [refetch, result].
refetch(input) — runs the query again with the given input (wrapped as variables.input).result — { data, loading, error, ... } from Apollo's useLazyQuery.import { useAuthQuery } from "naystack/graphql/client";
import { GET_SUMMARY } from "@/constants/graphql/queries";
function SummaryCard({ type }: { type: string }) {
const [getSummary, { loading, data }] = useAuthQuery(GET_SUMMARY);
const handleFetch = async () => {
const result = await getSummary({ type });
if (result.data?.getSummary) setSummary(result.data.getSummary);
};
return <button onClick={handleFetch} disabled={loading}>Get Summary</button>;
}
Hook to run a GraphQL query as the current user. Requests are sent with
credentials: "include", so the server identifies the user from the refresh cookie (theAuthorizationheader is deliberately not added on this path). The query auto-fires whenevervariablesis set and changes. Returns a refetch function and the Apollo query result.Defaults to
fetchPolicy: "no-cache"(always fresh, safe for viewer-keyed data). Override per-query viaoptions— e.g.{ fetchPolicy: "cache-first" }for static reference data, or{ fetchPolicy: "cache-and-network" }to show cached data instantly while refetching.