@graphql-typed-document-node/core
Advanced tools
Comparing version 3.2.0-alpha-20230205023330-f05a940 to 3.2.0-alpha-20230309104331-975d9d2
{ | ||
"name": "@graphql-typed-document-node/core", | ||
"version": "3.2.0-alpha-20230205023330-f05a940", | ||
"version": "3.2.0-alpha-20230309104331-975d9d2", | ||
"peerDependencies": { | ||
@@ -5,0 +5,0 @@ "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" |
import type { DocumentNode } from "graphql"; | ||
export type OperationResultType = "stream" | "single"; | ||
export interface TypedDocumentNode<Result = { | ||
[key: string]: any; | ||
}, Variables = { | ||
[key: string]: any; | ||
}, ResultType extends OperationResultType = any> extends DocumentNode { | ||
export interface DocumentTypeDecoration<TResult, TVariables> { | ||
/** | ||
@@ -13,4 +8,11 @@ * This type is used to ensure that the variables you pass in to the query are assignable to Variables | ||
*/ | ||
__apiType?: (variables: Variables, resultType: ResultType) => Result; | ||
__apiType?: (variables: TVariables) => TResult; | ||
} | ||
export interface TypedDocumentNode<TResult = { | ||
[key: string]: any; | ||
}, TVariables = { | ||
[key: string]: any; | ||
}> extends DocumentNode, DocumentTypeDecoration<TResult, TVariables> { | ||
} | ||
export type TypedDocumentString<TResult, TVariables> = string & DocumentTypeDecoration<TResult, TVariables>; | ||
/** | ||
@@ -22,3 +24,3 @@ * Helper for extracting a TypeScript type for operation result from a TypedDocumentNode. | ||
*/ | ||
export type ResultOf<T> = T extends TypedDocumentNode<infer ResultType, any> ? ResultType : never; | ||
export type ResultOf<T> = T extends TypedDocumentNode<infer ResultType, infer VariablesType> ? ResultType : never; | ||
/** | ||
@@ -30,9 +32,2 @@ * Helper for extracting a TypeScript type for operation variables from a TypedDocumentNode. | ||
*/ | ||
export type VariablesOf<T> = T extends TypedDocumentNode<any, infer VariablesType> ? VariablesType : never; | ||
/** | ||
* Helper for extracting a TypeScript type for operation type from a TypedDocumentNode. | ||
* @example | ||
* const myQuery = { ... }; // TypedDocumentNode<R, V, O> | ||
* type OperationType = VariablesOf<typeof myQuery>; // Now it's O | ||
*/ | ||
export type OperationTypeOf<T> = T extends TypedDocumentNode<any, any, infer OperationType> ? OperationType : never; | ||
export type VariablesOf<T> = T extends TypedDocumentNode<infer ResultType, infer VariablesType> ? VariablesType : never; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3039
30