Skip to content

Commit 7219ff0

Browse files
committed
try to fix
1 parent 2c88475 commit 7219ff0

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

functions/graphql.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type {
1111
} from '@netlify/functions';
1212

1313
import { schema } from '../packages/graphiql/test/schema.js';
14+
import { customExecute } from '../packages/graphiql/test/execute.js';
1415

1516
/**
1617
* Handler options when using the netlify adapter
@@ -56,4 +57,4 @@ export function createHandler<Context extends OperationContext = undefined>(
5657
};
5758
}
5859

59-
export const handler = createHandler({ schema });
60+
export const handler = createHandler({ schema, execute: customExecute });

packages/graphiql/test/e2e-server.js

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,17 @@ import { fileURLToPath } from 'node:url';
1212
import express from 'express';
1313
import { useServer } from 'graphql-ws/lib/use/ws';
1414
import { WebSocketServer } from 'ws';
15-
import { execute, experimentalExecuteIncrementally, version } from 'graphql';
1615
import {
1716
getGraphQLParameters,
1817
processRequest,
1918
sendResult,
2019
} from 'graphql-helix'; // update when `graphql-http` is upgraded to support multipart requests for incremental delivery https://github.com/graphql/graphiql/pull/3682#discussion_r1715545279
2120

2221
import { schema } from './schema.js';
22+
import { customExecute } from './execute.js';
2323

2424
const app = express();
2525

26-
const customExecute =
27-
parseInt(version, 10) > 16
28-
? async (...args) => {
29-
const result = await experimentalExecuteIncrementally(...args);
30-
31-
if (!('subsequentResults' in result)) {
32-
return result;
33-
}
34-
35-
const { initialResult, subsequentResults } = result;
36-
if (typeof subsequentResults[Symbol.asyncIterator] !== 'function') {
37-
return result;
38-
}
39-
40-
return (async function* () {
41-
yield initialResult;
42-
yield* subsequentResults;
43-
})();
44-
}
45-
: execute;
46-
4726
async function handler(req, res) {
4827
const request = {
4928
body: req.body,

packages/graphiql/test/execute.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { execute, experimentalExecuteIncrementally, version } from 'graphql';
2+
3+
export const customExecute =
4+
parseInt(version, 10) > 16
5+
? async (...args) => {
6+
const result = await experimentalExecuteIncrementally(...args);
7+
8+
if (!('subsequentResults' in result)) {
9+
return result;
10+
}
11+
12+
const { initialResult, subsequentResults } = result;
13+
if (typeof subsequentResults[Symbol.asyncIterator] !== 'function') {
14+
return result;
15+
}
16+
17+
return (async function* () {
18+
yield initialResult;
19+
yield* subsequentResults;
20+
})();
21+
}
22+
: execute;

0 commit comments

Comments
 (0)