Skip to content

Commit 01c64ac

Browse files
committed
Merge branch 'main' into abort-execution
2 parents 6fa5336 + 7a6d055 commit 01c64ac

File tree

109 files changed

+8858
-17639
lines changed

Some content is hidden

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

109 files changed

+8858
-17639
lines changed

.eslintrc.cjs

Lines changed: 842 additions & 0 deletions
Large diffs are not rendered by default.

.eslintrc.yml

Lines changed: 0 additions & 742 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,8 @@ jobs:
8484
- name: Install Dependencies
8585
run: npm ci --ignore-scripts
8686

87-
# Disabled due to https://github.com/milesj/docusaurus-plugin-typedoc-api/pull/19
88-
# - name: Check that package-lock.json doesn't have conflicts
89-
# run: npm ls --depth 999
87+
- name: Check that package-lock.json doesn't have conflicts
88+
run: npm ls --depth 999
9089

9190
- name: Run npm install
9291
run: npm install --ignore-scripts --force --package-lock-only --engine-strict --strict-peer-deps
@@ -146,7 +145,7 @@ jobs:
146145
runs-on: ubuntu-latest
147146
strategy:
148147
matrix:
149-
node_version_to_setup: [14, 16, 18]
148+
node_version_to_setup: [16, 18, 19]
150149
permissions:
151150
contents: read # for actions/checkout
152151
steps:

.node-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18
1+
v19

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,24 @@ through that README and the corresponding tests in parallel.
2323

2424
Install GraphQL.js from npm
2525

26-
With npm:
26+
With `npm`:
2727

2828
```sh
2929
npm install --save graphql
3030
```
3131

32-
or using yarn:
32+
With `yarn`:
3333

3434
```sh
3535
yarn add graphql
3636
```
3737

38+
With `bun`:
39+
40+
```sh
41+
bun add graphql
42+
```
43+
3844
GraphQL.js provides two important capabilities: building a type schema and
3945
serving queries against that type schema.
4046

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { graphqlSync } from 'graphql/graphql.js';
2+
import { buildSchema } from 'graphql/utilities/buildASTSchema.js';
3+
4+
const schema = buildSchema('type Query { hello: String! }');
5+
const source = `{ ${'hello '.repeat(250)}}`;
6+
7+
export const benchmark = {
8+
name: 'Many repeated fields',
9+
count: 5,
10+
measure() {
11+
graphqlSync({ schema, source });
12+
},
13+
};

integrationTests/node/index.cjs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
const assert = require('assert');
22
const { readFileSync } = require('fs');
33

4-
const { graphqlSync } = require('graphql');
4+
const {
5+
experimentalExecuteIncrementally,
6+
graphqlSync,
7+
parse,
8+
} = require('graphql');
59
const { buildSchema } = require('graphql/utilities');
610
const { version } = require('graphql/version');
711

@@ -12,7 +16,7 @@ assert.deepStrictEqual(
1216

1317
const schema = buildSchema('type Query { hello: String }');
1418

15-
const result = graphqlSync({
19+
let result = graphqlSync({
1620
schema,
1721
source: '{ hello }',
1822
rootValue: { hello: 'world' },
@@ -24,3 +28,27 @@ assert.deepStrictEqual(result, {
2428
hello: 'world',
2529
},
2630
});
31+
32+
/**
33+
* The below test triggers a call `invariant` method during execution (by
34+
* passing a negative number to the `initialCount` parameter on the `@stream`
35+
* directive). This ensures that the `inlineInvariant` method called by our
36+
* build script works correctly.
37+
**/
38+
39+
const experimentalSchema = buildSchema(`
40+
directive @stream(initialCount: Int!) on FIELD
41+
42+
type Query {
43+
greetings: [String]
44+
}
45+
`);
46+
47+
result = experimentalExecuteIncrementally({
48+
schema: experimentalSchema,
49+
document: parse('{ greetings @stream(initialCount: -1) }'),
50+
rootValue: { greetings: ['hi', 'hello'] },
51+
});
52+
53+
assert(result.errors?.[0] !== undefined);
54+
assert(!result.errors[0].message.includes('is not defined'));

integrationTests/node/index.mjs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
import assert from 'assert';
33
import { readFileSync } from 'fs';
44

5-
import { graphqlSync } from 'graphql-esm';
5+
import {
6+
experimentalExecuteIncrementally,
7+
graphqlSync,
8+
parse,
9+
} from 'graphql-esm';
610
import { buildSchema } from 'graphql-esm/utilities';
711
import { version } from 'graphql-esm/version';
812

@@ -13,7 +17,7 @@ assert.deepStrictEqual(
1317

1418
const schema = buildSchema('type Query { hello: String }');
1519

16-
const result = graphqlSync({
20+
let result = graphqlSync({
1721
schema,
1822
source: '{ hello }',
1923
rootValue: { hello: 'world' },
@@ -25,3 +29,27 @@ assert.deepStrictEqual(result, {
2529
hello: 'world',
2630
},
2731
});
32+
33+
/**
34+
* The below test triggers a call `invariant` method during execution (by
35+
* passing a negative number to the `initialCount` parameter on the `@stream`
36+
* directive). This ensures that the `inlineInvariant` method called by our
37+
* build script works correctly.
38+
**/
39+
40+
const experimentalSchema = buildSchema(`
41+
directive @stream(initialCount: Int!) on FIELD
42+
43+
type Query {
44+
greetings: [String]
45+
}
46+
`);
47+
48+
result = experimentalExecuteIncrementally({
49+
schema: experimentalSchema,
50+
document: parse('{ greetings @stream(initialCount: -1) }'),
51+
rootValue: { greetings: ['hi', 'hello'] },
52+
});
53+
54+
assert(result.errors?.[0] !== undefined);
55+
assert(!result.errors[0].message.includes('is not defined'));

integrationTests/node/test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ const graphqlPackageJSON = JSON.parse(
66
);
77

88
const nodeVersions = graphqlPackageJSON.engines.node
9+
.replaceAll('^', '')
10+
.replaceAll('>=', '')
911
.split(' || ')
10-
.map((version) => version.replace('^', '').replace('>=', ''))
1112
.sort((a, b) => b.localeCompare(a));
1213

1314
for (const version of nodeVersions) {

integrationTests/ts/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"typescript-4.6": "npm:[email protected]",
1414
"typescript-4.7": "npm:[email protected]",
1515
"typescript-4.8": "npm:[email protected]",
16-
"typescript-4.9": "npm:[email protected]"
16+
"typescript-4.9": "npm:[email protected]",
17+
"typescript-4.9": "npm:[email protected]"
1718
}
1819
}

integrationTests/webpack/test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import assert from 'assert';
22

3+
/* eslint-disable n/no-missing-import */
34
import cjs from './dist/main-cjs.cjs';
45
import mjs from './dist/main-mjs.cjs';
6+
/* eslint-enable n/no-missing-import */
57

68
assert.deepStrictEqual(cjs.result, {
79
data: {

0 commit comments

Comments
 (0)