Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Add support for graphql.js’ built-in TypedQueryDocumentNode #3085

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hungry-panthers-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@urql/core': patch
---

Add support for `graphql`’s built-in `TypedQueryDocumentNode` typings for type inference.
10 changes: 8 additions & 2 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { GraphQLError, DocumentNode } from 'graphql';
import type { GraphQLError, DocumentNode, DefinitionNode } from 'graphql';
import { Subscription, Source } from 'wonka';
import { Client } from './client';
import { CombinedError } from './utils/error';
Expand Down Expand Up @@ -26,10 +26,16 @@ export interface TypedDocumentNode<
Result = { [key: string]: any },
Variables = { [key: string]: any }
> extends DocumentNode {
/** Type to check whether `Variables` and `Result` are assignable types.
/** GraphQL.js Definition Nodes of the `DocumentNode`. */
readonly definitions: ReadonlyArray<DefinitionNode>;
/** Type to support `@graphql-typed-document-node/core`
* @internal
*/
__apiType?: (variables: Variables) => Result;
/** Type to support `TypedQueryDocumentNode` from `graphql`
* @internal
*/
__ensureTypesOfVariablesAndResultMatching?: (variables: Variables) => Result;
}

/** A list of errors on {@link ExecutionResult | ExecutionResults}.
Expand Down