Skip to content

Commit 80836fa

Browse files
saihajardatangithub-actions[bot]
authored
get defer/stream from graphql-js (#4796)
* get defer/stream from graphql-js * prettier * use agnostic root type getter * use createGraphQLError * fix issue with v15 and v16 cause of obj vs enum * Fix tests * Remove unused subscribe * Fix TS * Fix ESM * ESM fix * move collect fields to utils * chore(dependencies): updated changesets for modified dependencies * run prettier * make default execute incremental * chore(dependencies): updated changesets for modified dependencies * .. * chore(dependencies): updated changesets for modified dependencies * Sync * Use ValueOrPromise * chore(dependencies): updated changesets for modified dependencies * Fix * chore(dependencies): updated changesets for modified dependencies * Go * Go * stop Co-authored-by: Arda TANRIKULU <ardatanrikulu@gmail.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 691966b commit 80836fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+4675
-526
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@graphql-tools/executor': patch
3+
---
4+
dependencies updates:
5+
- Added dependency [`@repeaterjs/repeater@3.0.4` ↗︎](https://www.npmjs.com/package/@repeaterjs/repeater/v/3.0.4) (to `dependencies`)
6+
- Added dependency [`value-or-promise@1.0.1` ↗︎](https://www.npmjs.com/package/value-or-promise/v/1.0.1) (to `dependencies`)

.changeset/chatty-worms-pull.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-tools/utils': minor
3+
---
4+
5+
add `@defer` directive

.changeset/quick-clocks-beam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-tools/executor': patch
3+
---
4+
5+
get defer stream from graphql-js

.changeset/spotty-maps-approve.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-tools/utils': minor
3+
---
4+
5+
export collect field helpers

.changeset/spotty-suns-bake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-tools/utils': minor
3+
---
4+
5+
add `@stream` directive

.changeset/warm-bags-camp.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@graphql-tools/utils': major
3+
'@graphql-tools/delegate': patch
4+
'@graphql-tools/stitch': patch
5+
---
6+
7+
update `collectFields` to support collecting deffered values

packages/batch-delegate/tests/basic.example.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { execute } from '@graphql-tools/executor';
1+
import { execute, isIncrementalResult } from '@graphql-tools/executor';
22
import { OperationTypeNode, parse } from 'graphql';
33

44
import { makeExecutableSchema } from '@graphql-tools/schema';
@@ -89,6 +89,9 @@ describe('batch delegation within basic stitching example', () => {
8989
const result = await execute({ schema: stitchedSchema, document: parse(query) });
9090

9191
expect(numCalls).toEqual(1);
92+
93+
if (isIncrementalResult(result)) throw Error('result is incremental');
94+
9295
expect(result.errors).toBeUndefined();
9396
const chirps: any = result.data!['trendingChirps'];
9497
expect(chirps[0].chirpedAtUser.email).not.toBe(null);
@@ -182,6 +185,9 @@ describe('batch delegation within basic stitching example', () => {
182185

183186
const result = await execute({ schema: stitchedSchema, document: parse(query) });
184187
expect(numCalls).toEqual(1);
188+
189+
if (isIncrementalResult(result)) throw Error('result is incremental');
190+
185191
expect(result.data).toEqual({
186192
users: [
187193
{

packages/batch-delegate/tests/withTransforms.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { execute } from '@graphql-tools/executor';
1+
import { execute, isIncrementalResult } from '@graphql-tools/executor';
22
import { GraphQLList, GraphQLObjectType, Kind, OperationTypeNode, parse } from 'graphql';
33

44
import { makeExecutableSchema } from '@graphql-tools/schema';
@@ -121,6 +121,7 @@ describe('works with complex transforms', () => {
121121
`;
122122

123123
const result = await execute({ schema: stitchedSchema, document: parse(query) });
124+
if (isIncrementalResult(result)) throw Error('result is incremental');
124125

125126
expect(result.errors).toBeUndefined();
126127
expect(result.data).toEqual({

packages/batch-execute/tests/batchExecute.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { parse, print, OperationDefinitionNode, validate } from 'graphql';
22
import { makeExecutableSchema } from '@graphql-tools/schema';
33
import { createBatchingExecutor } from '@graphql-tools/batch-execute';
44
import { ExecutionResult, Executor } from '@graphql-tools/utils';
5-
import { execute } from '@graphql-tools/executor';
5+
import { normalizedExecutor } from '@graphql-tools/executor';
66

77
describe('batch execution', () => {
88
let executorCalls = 0;
@@ -41,7 +41,7 @@ describe('batch execution', () => {
4141
if (errors.length > 0) {
4242
return { errors };
4343
}
44-
return execute({
44+
return normalizedExecutor({
4545
schema,
4646
document,
4747
variableValues: executorVariables,

packages/delegate/src/delegateToSchema.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { Subschema } from './Subschema.js';
3636
import { createRequest, getDelegatingOperation } from './createRequest.js';
3737
import { Transformer } from './Transformer.js';
3838
import { applySchemaTransforms } from './applySchemaTransforms.js';
39-
import { ExecutionArgs, execute, subscribe } from '@graphql-tools/executor';
39+
import { normalizedExecutor } from '@graphql-tools/executor';
4040

4141
export function delegateToSchema<
4242
TContext extends Record<string, any> = Record<string, any>,
@@ -219,18 +219,13 @@ function getExecutor<TContext extends Record<string, any>>(
219219

220220
export const createDefaultExecutor = memoize1(function createDefaultExecutor(schema: GraphQLSchema): Executor {
221221
return function defaultExecutor(request: ExecutionRequest) {
222-
const executionArgs: ExecutionArgs = {
222+
return normalizedExecutor({
223223
schema,
224224
document: request.document,
225225
rootValue: request.rootValue,
226226
contextValue: request.context,
227227
variableValues: request.variables,
228228
operationName: request.operationName,
229-
};
230-
const operationType = request.operationType || getOperationASTFromRequest(request).operation;
231-
if (operationType === 'subscription') {
232-
return subscribe(executionArgs);
233-
}
234-
return execute(executionArgs);
229+
});
235230
};
236231
});

0 commit comments

Comments
 (0)