Conversation
…ntNode Change GraphQLClient.request to accept a TypedDocumentNode<TResult, TVariables> so both the result and variables types are inferred from the generated document. This removes redundant explicit generic type arguments across resolvers and services and lets TypeScript catch mismatched documents, result types, and variables at the call site. Adds the @graphql-typed-document-node/core dependency. Closes #194
✅ knip — no dead codeNo unused files, exports, types, or dependencies detected. |
The TypedDocumentNode import is type-only and fully erased at build, and linearis ships CLI JS only (declaration: false, no published types), so a consumer never needs the package at runtime. Classify it as a dev dependency to match reality; revisit if declarations are ever shipped, since the type surfaces in GraphQLClient.request. Refs #194
Constrain the variables generic to `Record<string, unknown>` so `variables` satisfies rawRequest's own bound directly, removing the variables cast and rejecting untyped documents. Replace the unconditional `data as TResult` assertion with a null guard so a dataless response throws a clear error instead of returning a `TResult`-typed `undefined`. Refs #194
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Changes
GraphQLClient.requestto accept aTypedDocumentNode<TResult, TVariables>so both the result and variables types are inferred directly from the codegen-generated document, and makes the variables argument optional only for variable-less operations. This removes ~300 lines of redundant explicit generic type arguments across every resolver and service, and lets TypeScript catch mismatched documents, result types, or variables at each call site. Adds the@graphql-typed-document-node/coredependency.Closes #194
Type of change
Checklist
npm run check:cipasses (lint + format)npx tsc --noEmitpasses (type check)npm testpasses (unit tests)Testing
npm run check:ci,npx tsc --noEmit, andnpm testall pass. No new tests added — this is a type-only refactor with no behavior change, covered by the existing suite.Notes for reviewers
Type safety now flows from the generated document, so the previous
as TResultcasts and per-call generics are gone. The one remaining cast is at therawRequestboundary ingraphql-client.ts, which only accepts an untyped variables bag; the public signature stays strongly typed viaTypedDocumentNode.