Skip to content
TypeWire

@tahanabavi/typefetch-graphql

documents v0.0.0

GraphQL transport for TypeFetch contracts — one client, one middleware chain, and selection sets generated from your Zod response schema.

Endpoint fields

FieldRequiredMeaning
operationyes"query" or "mutation"
rootThe single field to unwrap, so response describes data.user rather than data. Also the field the variables attach to as arguments.
documentA hand-written operation. Omit it to have one generated.
operationNameDefaults to the endpoint id in PascalCase (user.getUserGet).
variableTypesGraphQL types for variables the Zod type cannot name — { id: "ID!" }.
errorPolicy"none" (default) or "all". See below.

Everything transport-independent — auth, permission, errors, mockData, headers, test — works exactly as it does for an HTTP endpoint.

Variable types

Inferred from the request schema: z.string()String!, z.number().int()Int!, z.number()Float!, z.boolean()Boolean!, z.array(z.string())[String!]!, and .optional() drops the !.

Two cases need naming by hand, because nothing in the Zod type could say otherwise:

  • IDz.string() generates String!, which a server expecting ID! rejects. Write variableTypes: { id: "ID!" }.

  • Input objects — a Zod object cannot name a GraphQL input type. Write variableTypes: { input: "CreateUserInput!" }.