A TypedDocumentNode (e.g. from codegen) defining the query and its result type.
Optionaloptions: { noCookie?: boolean; revalidate?: number; tags?: string[]; variables?: V }Optional query options.
OptionalnoCookie?: booleanIf true, the request is sent without cookies (unauthenticated).
Optionalrevalidate?: numberNext.js revalidate in seconds; when set, enables caching with this TTL.
Optionaltags?: string[]Next.js cache tags for on-demand revalidation.
Optionalvariables?: VVariables object for the query (must match the document's variable types).
Promise resolving to the query result data (typed by the document).
import { query } from "naystack/graphql/server";
import { GetUserDocument } from "@/generated/graphql";
// In a Server Component:
const data = await query(GetUserDocument, {
variables: { id: userId },
revalidate: 60, // Cache for 60s (Next.js ISR)
tags: ["user"], // For on-demand revalidation
});
return <Profile user={data.user} />;
Runs a raw GraphQL query on the server using the registered Apollo client. Cookies are forwarded automatically so the backend can identify the user.
Use this in Server Components, Server Actions, or route handlers when you need to run a query against the GraphQL endpoint (rather than calling a resolver directly with
.call()/.authCall()).Supports Next.js ISR via
revalidateand on-demand revalidation viatags.