A TypedDocumentNode for the query (e.g. from codegen or a gql template).
Optionalvariables: VOptional initial variables. Query fires automatically when this and token are set; change to refetch.
Tuple: [refetch, result].
refetch(input) — runs the query again with the given input (passed as variables.input).result — { data, loading, error } from Apollo.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 with the current user's token. The query auto-fires when both the token and variables are available. Returns a refetch function and the Apollo query result.
Uses
fetchPolicy: "no-cache"by default to always get fresh data.