@nyxapi/graphql
v0.1.0
Published
GraphQL runtime for NyxAPI: typed queries and mutations on the same cache, retries and optimistic updates as REST
Maintainers
Readme
@nyxapi/graphql
GraphQL runtime for NyxAPI. A client generated by nyx generate from a GraphQL schema is built on this package, so GraphQL operations get the same cache, single-flight dedup, retries, cancellation and optimistic updates as REST endpoints.
nyx generate --input ./schema.graphql --output ./src/gqlimport { GraphQLClient } from "@nyxapi/graphql";
import { createApi } from "./gql/index.js";
const client = new GraphQLClient({ url: "https://api.example.com/graphql", getToken: () => token });
const api = createApi(client);
const user = await api.query.user({ id: "1" }); // typed from the selection set that is sent
const options = api.query.user.options({ id: "1" }); // useQuery / queryClient.fetchQuery
await api.query.user.invalidate({ id: "1" });- Result types come from the exact selection set in the generated document, so type and query cannot drift.
- Requests go through the origin-pinned
HttpClientfrom@nyxapi/core(timeouts, middleware,maxResponseBytes). - A response with
errorsrejects withGraphQLError(never retried);errorPolicy: "all"resolves with partial data. HTTP and network failures use core's typed errors and retry rules. - Subscriptions are not supported.
