Skip to content

Commit 2775f81

Browse files
committed
Merge remote-tracking branch 'origin/next' into schema-coordinates
2 parents fe0ad30 + 9e4f796 commit 2775f81

File tree

113 files changed

+4077
-2023
lines changed

Some content is hidden

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

113 files changed

+4077
-2023
lines changed

.mocharc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ check-leaks: true
44
extension:
55
- ts
66
node-option:
7-
- 'loader=ts-node/esm/transpile-only'
7+
- 'import=./resources/register-ts-node.js'

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,11 @@ tool is built with GraphQL.js!
131131
Building a project using GraphQL.js with [webpack](https://webpack.js.org) or
132132
[rollup](https://github.com/rollup/rollup) should just work and only include
133133
the portions of the library you use. This works because GraphQL.js is distributed
134-
with both CommonJS (`require()`) and ESModule (`import`) files. Ensure that any
135-
custom build configurations look for `.mjs` files!
134+
with both CommonJS (`require()`) and ESModule (`import`) files. The `exports`
135+
map within the project `package.json` should direct runtimes and bundlers to
136+
the appropriate files. Tools that do not support `exports` will find the CommonJS
137+
and ESModule builds side by side, with the CommonJS code packaged
138+
in files with the `.js` extension and the ESModule build within `.mjs` files.
136139

137140
## Contributing
138141

cspell.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@ words:
6767

6868
# TODO: contribute upstream
6969
- deno
70+
- denoland
7071
- hashbang
72+
- vitest
73+
- Rollup
74+
- Rspack
75+
- Rsbuild
76+
- Turbopack
7177

7278
# Website tech
7379
- Nextra

eslint.config.mjs

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default tsConfig(
5555
'internal-rules/require-to-string-tag': 'off',
5656

5757
//////////////////////////////////////////////////////////////////////////////
58-
// `eslint-plugin-n` rule list based on `v17.14.x`
58+
// `eslint-plugin-n` rule list based on `v17.21.x`
5959
//////////////////////////////////////////////////////////////////////////////
6060

6161
// Rules
@@ -82,6 +82,7 @@ export default tsConfig(
8282
'n/no-restricted-import': 'off',
8383
'n/no-restricted-require': 'off',
8484
'n/no-sync': 'off', // TODO: consider enabling, currently triggers with executeSync/graphqlSync, without ability to add exceptions
85+
'n/no-top-level-await': 'error',
8586
'n/no-unpublished-bin': 'error',
8687
'n/no-unpublished-import': 'error',
8788
'n/no-unpublished-require': 'error',
@@ -105,12 +106,13 @@ export default tsConfig(
105106
'n/shebang': 'error',
106107

107108
//////////////////////////////////////////////////////////////////////////////
108-
// `eslint-plugin-import` rule list based on `v2.31.x`
109+
// `eslint-plugin-import` rule list based on `v2.32.x`
109110
//////////////////////////////////////////////////////////////////////////////
110111

111112
// Static analysis
112113
// https://github.com/benmosher/eslint-plugin-import#static-analysis
113114
'import/default': 'error',
115+
'import/enforce-node-protocol-usage': ['error', 'always'],
114116
'import/named': 'error',
115117
'import/namespace': 'error',
116118
'import/no-absolute-path': 'error',
@@ -228,7 +230,7 @@ export default tsConfig(
228230
'simple-import-sort/exports': 'off', // TODO: error
229231

230232
//////////////////////////////////////////////////////////////////////////////
231-
// ESLint builtin rules list based on `v9.16.x`
233+
// ESLint builtin rules list based on `v9.31.x`
232234
//////////////////////////////////////////////////////////////////////////////
233235

234236
// Possible Errors
@@ -275,6 +277,7 @@ export default tsConfig(
275277
'no-sparse-arrays': 'error',
276278
'no-template-curly-in-string': 'error',
277279
'no-this-before-super': 'error',
280+
'no-unassigned-vars': 'error',
278281
'no-undef': 'error',
279282
'no-unexpected-multiline': 'error',
280283
'no-unmodified-loop-condition': 'error',
@@ -492,7 +495,7 @@ export default tsConfig(
492495
},
493496
rules: {
494497
//////////////////////////////////////////////////////////////////////////
495-
// `@typescript-eslint/eslint-plugin` rule list based on `v8.16.x`
498+
// `@typescript-eslint/eslint-plugin` rule list based on `v8.37.x`
496499
//////////////////////////////////////////////////////////////////////////
497500

498501
// Supported Rules
@@ -513,7 +516,7 @@ export default tsConfig(
513516
],
514517
'@typescript-eslint/ban-tslint-comment': 'error',
515518
'@typescript-eslint/class-literal-property-style': 'off', // TODO: enable after TS conversion
516-
'@typescript-eslint/class-methods-use-this': 'off',
519+
'@typescript-eslint/class-methods-use-this': 'off', // now in core
517520
'@typescript-eslint/consistent-generic-constructors': 'error',
518521
'@typescript-eslint/consistent-indexed-object-style': [
519522
'error',
@@ -524,32 +527,27 @@ export default tsConfig(
524527
'@typescript-eslint/consistent-type-definitions': 'error',
525528
'@typescript-eslint/consistent-type-exports': 'error',
526529
'@typescript-eslint/consistent-type-imports': 'error',
527-
'@typescript-eslint/default-param-last': 'error',
530+
'@typescript-eslint/default-param-last': 'off', // now in core
528531
'@typescript-eslint/dot-notation': 'error',
529532
'@typescript-eslint/explicit-function-return-type': 'off', // TODO: consider
530533
'@typescript-eslint/explicit-member-accessibility': 'off', // TODO: consider
531534
'@typescript-eslint/explicit-module-boundary-types': 'off', // TODO: consider
532-
'@typescript-eslint/init-declarations': 'off',
533-
'@typescript-eslint/max-params': [
534-
'error',
535-
{
536-
max: 5, // TODO: drop to default number, which is 3
537-
},
538-
],
535+
'@typescript-eslint/init-declarations': 'off', // now in core
536+
'@typescript-eslint/max-params': 'off', // now in core
539537
'@typescript-eslint/member-ordering': 'error',
540538
'@typescript-eslint/method-signature-style': 'error',
541539
'@typescript-eslint/naming-convention': 'off',
542-
'@typescript-eslint/no-array-constructor': 'error',
540+
'@typescript-eslint/no-array-constructor': 'off', // now in core
543541
'@typescript-eslint/no-array-delete': 'error',
544542
'@typescript-eslint/no-base-to-string': 'error',
545543
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
546544
'@typescript-eslint/no-confusing-void-expression': 'off', // TODO: enable with ignoreArrowShorthand
547545
'@typescript-eslint/no-deprecated': 'off',
548-
'@typescript-eslint/no-dupe-class-members': 'error',
546+
'@typescript-eslint/no-dupe-class-members': 'off', // now in core
549547
'@typescript-eslint/no-duplicate-enum-values': 'error',
550548
'@typescript-eslint/no-duplicate-type-constituents': 'error',
551549
'@typescript-eslint/no-dynamic-delete': 'off',
552-
'@typescript-eslint/no-empty-function': 'error',
550+
'@typescript-eslint/no-empty-function': 'off', // now in core
553551
'@typescript-eslint/no-empty-object-type': 'error',
554552
'@typescript-eslint/no-explicit-any': 'off', // TODO: error
555553
'@typescript-eslint/no-extra-non-null-assertion': 'error',
@@ -565,10 +563,10 @@ export default tsConfig(
565563
ignoreProperties: true,
566564
},
567565
],
568-
'@typescript-eslint/no-invalid-this': 'error',
566+
'@typescript-eslint/no-invalid-this': 'off', // now in core
569567
'@typescript-eslint/no-invalid-void-type': 'error',
570568
'@typescript-eslint/no-loop-func': 'error',
571-
'@typescript-eslint/no-magic-numbers': 'off',
569+
'@typescript-eslint/no-magic-numbers': 'off', // now in core
572570
'@typescript-eslint/no-meaningless-void-operator': 'error',
573571
'@typescript-eslint/no-misused-new': 'error',
574572
'@typescript-eslint/no-misused-promises': 'error',
@@ -582,7 +580,7 @@ export default tsConfig(
582580
'@typescript-eslint/no-require-imports': 'error',
583581
'@typescript-eslint/no-restricted-imports': 'error',
584582
'@typescript-eslint/no-restricted-types': 'error',
585-
'@typescript-eslint/no-shadow': 'error',
583+
'@typescript-eslint/no-shadow': 'off', // now in core
586584
'@typescript-eslint/no-this-alias': 'error',
587585
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
588586
'@typescript-eslint/no-unnecessary-condition': 'off', // TODO: temporary disable
@@ -604,7 +602,7 @@ export default tsConfig(
604602
'@typescript-eslint/no-unsafe-return': 'off', // TODO: consider
605603
'@typescript-eslint/no-unsafe-type-assertion': 'off', // TODO: consider
606604
'@typescript-eslint/no-unsafe-unary-minus': 'error',
607-
'@typescript-eslint/no-unused-expressions': 'error',
605+
'@typescript-eslint/no-unused-expressions': 'off', // now in core
608606
'@typescript-eslint/no-unused-vars': [
609607
'error',
610608
{
@@ -617,8 +615,8 @@ export default tsConfig(
617615
ignoreRestSiblings: true,
618616
},
619617
],
620-
'@typescript-eslint/no-use-before-define': 'off',
621-
'@typescript-eslint/no-useless-constructor': 'error',
618+
'@typescript-eslint/no-use-before-define': 'off', // now in core
619+
'@typescript-eslint/no-useless-constructor': 'off', // now in core
622620
'@typescript-eslint/no-useless-empty-export': 'error',
623621
'@typescript-eslint/no-wrapper-object-types': 'error',
624622
'@typescript-eslint/non-nullable-type-assertion-style': 'off', //TODO: temporarily disabled
@@ -672,26 +670,13 @@ export default tsConfig(
672670

673671
// Below list intentionally includes ESLint rules disabled above.
674672
// If any of the above rules are enabled in the future, they must still be disabled for TS files.
675-
'class-methods-use-this': 'off',
676673
'consistent-return': 'off',
677-
'default-param-last': 'off',
678674
'dot-notation': 'off',
679-
'init-declarations': 'off',
680-
'max-params': 'off',
681-
'no-array-constructor': 'off',
682-
'no-dupe-class-members': 'off',
683-
'no-empty-function': 'off',
684675
'no-implied-eval': 'off',
685-
'no-invalid-this': 'off',
686676
'no-loop-func': 'off',
687-
'no-magic-numbers': 'off',
688677
'no-redeclare': 'off',
689678
'no-restricted-imports': 'off',
690-
'no-shadow': 'off',
691-
'no-unused-expressions': 'off',
692679
'no-unused-vars': 'off',
693-
'no-use-before-define': 'off',
694-
'no-useless-constructor': 'off',
695680
'only-throw-error': 'off',
696681
'prefer-destructuring': 'off',
697682
'prefer-promise-reject-errors': 'off',
@@ -816,7 +801,10 @@ export default tsConfig(
816801
allowEmoji: true,
817802
},
818803
],
804+
'n/no-top-level-await': 'off',
819805
// TODO: remove when fetch/cpSync stabilizes across all node versions
806+
// fetch is not supported until Node.js 21.0.0
807+
// fs.cpSync is not supported until Node.js 22.3.0
820808
'n/no-unsupported-features/node-builtins': [
821809
'error',
822810
{

integrationTests/README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,27 @@
1-
# TBD
1+
# Integration Tests
2+
3+
This directory contains integration tests for GraphQL.js across different environments and bundlers, testing basic GraphQL.JS functionality, as well as development mode and production mode behavior.
4+
5+
Tests are run via the main integration test suite in `resources/integration-test.ts`.
6+
7+
## Test Structure
8+
9+
### Basic GraphQL.JS Functionality Tests
10+
11+
Each subdirectory represents a different environment/bundler:
12+
13+
- `node` - tests for supported Node.js versions
14+
- `ts` - tests for supported Typescript versions
15+
- `webpack` - tests for Webpack
16+
17+
### Verifying Conditional Exports
18+
19+
The `conditions` subdirectory contains tests that verify the conditional exports of GraphQL.js. These tests ensure that the correct files are imported based on the environment being used.
20+
21+
### Verifying Development Mode Tests
22+
23+
Each subdirectory represents a different platform/bundler demonstrating enabling development mode by enabling the `development` condition or by calling `enableDevMode()`.
24+
25+
### Verifying Production Mode Tests
26+
27+
Each subdirectory represents a different environment/bundler demonstrating production mode when development mode is not enabled.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import assert from 'node:assert';
2+
3+
import { GraphQLObjectType as ESMGraphQLObjectType } from 'graphql';
4+
5+
import { CJSGraphQLObjectType, cjsPath } from './cjs-importer.cjs';
6+
7+
const moduleSync = process.env.MODULE_SYNC === 'true';
8+
const expectedExtension = moduleSync ? '.mjs' : '.js';
9+
assert.ok(
10+
cjsPath.endsWith(expectedExtension),
11+
`require('graphql') should resolve to a file with extension "${expectedExtension}", but got "${cjsPath}".`,
12+
);
13+
14+
const isSameModule = ESMGraphQLObjectType === CJSGraphQLObjectType;
15+
assert.strictEqual(
16+
isSameModule,
17+
true,
18+
'ESM and CJS imports should be the same module instances.',
19+
);
20+
21+
console.log('Module identity and path checks passed.');
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
const { GraphQLObjectType } = require('graphql');
4+
5+
const cjsPath = require.resolve('graphql');
6+
7+
// eslint-disable-next-line import/no-commonjs
8+
module.exports = {
9+
CJSGraphQLObjectType: GraphQLObjectType,
10+
cjsPath,
11+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"description": "graphql-js should be loaded correctly on different versions of Node.js, Deno and Bun",
3+
"private": true,
4+
"scripts": {
5+
"test": "node test.js"
6+
},
7+
"dependencies": {
8+
"graphql": "file:../graphql.tgz"
9+
}
10+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import childProcess from 'node:child_process';
2+
3+
const nodeTests = [
4+
// Old node versions, require => CJS
5+
{ version: '20.18.0', moduleSync: false },
6+
{ version: '22.11.0', moduleSync: false },
7+
// New node versions, module-sync => ESM
8+
{ version: '20.19.0', moduleSync: true },
9+
{ version: '22.12.0', moduleSync: true },
10+
{ version: '24.0.0', moduleSync: true },
11+
];
12+
13+
for (const { version, moduleSync } of nodeTests) {
14+
console.log(`Testing on node@${version} (moduleSync: ${moduleSync}) ...`);
15+
childProcess.execSync(
16+
`docker run --rm --volume "$PWD":/usr/src/app -w /usr/src/app --env MODULE_SYNC=${moduleSync} node:${version}-slim node ./check.mjs`,
17+
{ stdio: 'inherit' },
18+
);
19+
}
20+
21+
console.log('Testing on bun (moduleSync: true) ...');
22+
childProcess.execSync(
23+
`docker run --rm --volume "$PWD":/usr/src/app -w /usr/src/app --env MODULE_SYNC=true oven/bun:"$BUN_VERSION"-slim bun ./check.mjs`,
24+
{ stdio: 'inherit' },
25+
);
26+
27+
console.log('Testing on deno (moduleSync: false) ...');
28+
childProcess.execSync(
29+
`docker run --rm --volume "$PWD":/usr/src/app -w /usr/src/app --env MODULE_SYNC=false denoland/deno:alpine-"$DENO_VERSION" deno run --allow-read --allow-env ./check.mjs`,
30+
{ stdio: 'inherit' },
31+
);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"description": "graphql-js development mode should work with Bun",
3+
"private": true,
4+
"scripts": {
5+
"test": "docker run --rm --volume \"$PWD\":/usr/src/app -w /usr/src/app oven/bun:\"$BUN_VERSION\"-slim bun --conditions=development test.js"
6+
},
7+
"dependencies": {
8+
"graphql": "file:../graphql.tgz"
9+
}
10+
}

0 commit comments

Comments
 (0)