Skip to content

Commit

Permalink
feat(executor): support TypedDocumentNode
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Feb 1, 2023
1 parent 10cbbf5 commit a94217e
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-news-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-tools/utils': minor
---

Support TypedDocumentNode in ExecutionRequest
2 changes: 1 addition & 1 deletion packages/batch-execute/tests/batchExecute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { normalizedExecutor } from '@graphql-tools/executor';
describe('batch execution', () => {
let executorCalls = 0;
let executorDocument: string | undefined;
let executorVariables: Record<string, any> | undefined;
let executorVariables: any | undefined;

const schema = makeExecutableSchema({
typeDefs: /* GraphQL */ `
Expand Down
1 change: 1 addition & 0 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"graphql-scalars": "1.20.1"
},
"dependencies": {
"@graphql-typed-document-node/core": "^3.1.1",
"tslib": "^2.4.0"
},
"publishConfig": {
Expand Down
10 changes: 6 additions & 4 deletions packages/utils/src/Interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
import {
GraphQLSchema,
GraphQLField,
Expand Down Expand Up @@ -68,13 +69,14 @@ export interface ExecutionResult<TData = any, TExtensions = any> {
}

export interface ExecutionRequest<
TArgs extends Record<string, any> = Record<string, any>,
TVariables extends Record<string, any> = any,
TContext = any,
TRootValue = any,
TExtensions = Record<string, any>
TExtensions = Record<string, any>,
TReturn = any
> {
document: DocumentNode;
variables?: TArgs;
document: TypedDocumentNode<TReturn, TVariables>;
variables?: TVariables;
// TODO: Will be removed in next major
operationType?: OperationTypeNode;
operationName?: string;
Expand Down
6 changes: 3 additions & 3 deletions packages/utils/src/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type AsyncExecutor<TBaseContext = Record<string, any>, TBaseExtensions =
TRoot = any,
TExtensions extends TBaseExtensions = TBaseExtensions
>(
request: ExecutionRequest<TArgs, TContext, TRoot, TExtensions>
request: ExecutionRequest<TArgs, TContext, TRoot, TExtensions, TReturn>
) => Promise<MaybeAsyncIterable<ExecutionResult<TReturn>>>;

export type SyncExecutor<TBaseContext = Record<string, any>, TBaseExtensions = Record<string, any>> = <
Expand All @@ -20,7 +20,7 @@ export type SyncExecutor<TBaseContext = Record<string, any>, TBaseExtensions = R
TRoot = any,
TExtensions extends TBaseExtensions = TBaseExtensions
>(
request: ExecutionRequest<TArgs, TContext, TRoot, TExtensions>
request: ExecutionRequest<TArgs, TContext, TRoot, TExtensions, TReturn>
) => ExecutionResult<TReturn>;

export type Executor<TBaseContext = Record<string, any>, TBaseExtensions = Record<string, any>> = <
Expand All @@ -30,5 +30,5 @@ export type Executor<TBaseContext = Record<string, any>, TBaseExtensions = Recor
TRoot = any,
TExtensions extends TBaseExtensions = TBaseExtensions
>(
request: ExecutionRequest<TArgs, TContext, TRoot, TExtensions>
request: ExecutionRequest<TArgs, TContext, TRoot, TExtensions, TReturn>
) => MaybePromise<MaybeAsyncIterable<ExecutionResult<TReturn>>>;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/node_modules/typedoc-plugin-markdown/dist/resources/helpers/declaration-title.js b/node_modules/typedoc-plugin-markdown/dist/resources/helpers/declaration-title.js
index c8529a5..4dadab7 100644
index c8529a5..7f884c9 100644
--- a/node_modules/typedoc-plugin-markdown/dist/resources/helpers/declaration-title.js
+++ b/node_modules/typedoc-plugin-markdown/dist/resources/helpers/declaration-title.js
@@ -20,9 +20,9 @@ function default_1(theme) {
Expand All @@ -15,7 +15,7 @@ index c8529a5..4dadab7 100644
md.push(getType(this));
if (!(this.type instanceof typedoc_1.LiteralType) &&
diff --git a/node_modules/typedoc-plugin-markdown/dist/resources/helpers/reflection-title.js b/node_modules/typedoc-plugin-markdown/dist/resources/helpers/reflection-title.js
index 24bbd50..70a032d 100644
index 24bbd50..12e5c61 100644
--- a/node_modules/typedoc-plugin-markdown/dist/resources/helpers/reflection-title.js
+++ b/node_modules/typedoc-plugin-markdown/dist/resources/helpers/reflection-title.js
@@ -19,7 +19,7 @@ function default_1(theme) {
Expand All @@ -28,7 +28,7 @@ index 24bbd50..70a032d 100644
}
return title.join('');
diff --git a/node_modules/typedoc-plugin-markdown/dist/resources/helpers/signature-title.js b/node_modules/typedoc-plugin-markdown/dist/resources/helpers/signature-title.js
index 1d547e1..69766f8 100644
index 38ade0b..77b86c1 100644
--- a/node_modules/typedoc-plugin-markdown/dist/resources/helpers/signature-title.js
+++ b/node_modules/typedoc-plugin-markdown/dist/resources/helpers/signature-title.js
@@ -20,9 +20,9 @@ function default_1(theme) {
Expand All @@ -44,7 +44,7 @@ index 1d547e1..69766f8 100644
md.push(`(${getParameters(this.parameters)})`);
if (this.type && !((_b = this.parent) === null || _b === void 0 ? void 0 : _b.kindOf(typedoc_1.ReflectionKind.Constructor))) {
diff --git a/node_modules/typedoc-plugin-markdown/dist/resources/helpers/type.js b/node_modules/typedoc-plugin-markdown/dist/resources/helpers/type.js
index 14c33a7..cad815e 100644
index 8569286..88fe68d 100644
--- a/node_modules/typedoc-plugin-markdown/dist/resources/helpers/type.js
+++ b/node_modules/typedoc-plugin-markdown/dist/resources/helpers/type.js
@@ -90,7 +90,7 @@ function getDeclarationType(model) {
Expand All @@ -68,7 +68,7 @@ index 14c33a7..cad815e 100644
: [];
const params = fn.parameters
? fn.parameters.map((param) => {
@@ -128,9 +128,9 @@ function getReferenceType(model, emphasis) {
@@ -127,9 +127,9 @@ function getReferenceType(model, emphasis) {
: `\`${model.name}\``);
}
if (model.typeArguments && model.typeArguments.length > 0) {
Expand All @@ -81,7 +81,7 @@ index 14c33a7..cad815e 100644
return reflection.join('');
}
diff --git a/node_modules/typedoc-plugin-markdown/dist/utils.js b/node_modules/typedoc-plugin-markdown/dist/utils.js
index 051d9c6..4dc54b5 100644
index f254aed..5e1e3b1 100644
--- a/node_modules/typedoc-plugin-markdown/dist/utils.js
+++ b/node_modules/typedoc-plugin-markdown/dist/utils.js
@@ -11,7 +11,8 @@ function formatContents(contents) {
Expand Down

0 comments on commit a94217e

Please sign in to comment.