Skip to content

Commit df33fc4

Browse files
committed
WIP
1 parent d295901 commit df33fc4

19 files changed

+77
-280
lines changed

integrationTests/integration-test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ describe('Integration Tests', () => {
5353
}
5454

5555
testOnNodeProject('ts');
56-
testOnNodeProject('ts-esm');
5756
testOnNodeProject('node');
5857
testOnNodeProject('node-esm');
5958
testOnNodeProject('webpack');
60-
testOnNodeProject('webpack-esm');
6159
});

integrationTests/node-esm/index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
/* eslint-disable node/no-missing-import, import/no-unresolved */
22

33
import { deepStrictEqual, strictEqual } from 'assert';
4-
import { readFileSync } from 'fs';
54

65
// Regular import
76
import { graphqlSync } from 'graphql';
8-
// import with explicit extension
7+
// Import with explicit extension
98
import { version } from 'graphql/version.js';
109
// _/index.js import
1110
import { buildSchema } from 'graphql/utilities';
12-
// import without explicit extension
11+
// Import without explicit extension
1312
import { isPromise } from 'graphql/jsutils/isPromise';
1413

15-
deepStrictEqual(
16-
version,
17-
JSON.parse(readFileSync('./node_modules/graphql/package.json')).version,
18-
);
14+
// Import package.json
15+
import pkg from 'graphql/package.json';
16+
17+
deepStrictEqual(version, pkg.version);
1918

2019
const schema = buildSchema('type Query { hello: String }');
2120

@@ -33,3 +32,8 @@ deepStrictEqual(result, {
3332
});
3433

3534
strictEqual(isPromise(Promise.resolve()), true);
35+
36+
// The possible promise rejection is handled by "--unhandled-rejections=strict"
37+
import('graphql/jsutils/isPromise').then(({ isPromise }) => {
38+
strictEqual(isPromise(Promise.resolve()), true);
39+
});

integrationTests/node-esm/test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@ for (const version of nodeVersions) {
1414
console.log(`Testing on ${version} ...`);
1515

1616
const nodePath = resolve('node_modules', version, 'bin/node');
17-
execSync(nodePath + ' index.js', { stdio: 'inherit' });
17+
execSync(
18+
nodePath +
19+
' --experimental-json-modules --unhandled-rejections=strict index.js',
20+
{ stdio: 'inherit' },
21+
);
1822
}

integrationTests/ts-esm/TypedQueryDocumentNode-test.ts

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

integrationTests/ts-esm/extensions-test.ts

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

integrationTests/ts-esm/internalImports-test.ts

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

integrationTests/ts-esm/package.json

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

integrationTests/ts-esm/test.js

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

integrationTests/ts-esm/tsconfig.json

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
1-
import type { ExecutionResult } from 'graphql/execution';
2-
3-
import { graphqlSync } from 'graphql';
4-
import { GraphQLString, GraphQLSchema, GraphQLObjectType } from 'graphql/type';
5-
6-
const queryType: GraphQLObjectType = new GraphQLObjectType({
7-
name: 'Query',
8-
fields: () => ({
9-
sayHi: {
10-
type: GraphQLString,
11-
args: {
12-
who: {
13-
type: GraphQLString,
14-
defaultValue: 'World',
15-
},
16-
},
17-
resolve(_root, args: { who: string }) {
18-
return 'Hello ' + args.who;
19-
},
20-
},
21-
}),
22-
});
23-
24-
const schema: GraphQLSchema = new GraphQLSchema({ query: queryType });
25-
26-
const result: ExecutionResult = graphqlSync({
27-
schema,
28-
source: `
29-
query helloWho($who: String){
30-
test(who: $who)
31-
}
32-
`,
33-
variableValues: { who: 'Dolly' },
34-
});
1+
import type { ExecutionResult } from 'graphql-esm/execution';
2+
3+
import { graphqlSync } from 'graphql-esm';
4+
import {
5+
GraphQLString,
6+
GraphQLSchema,
7+
GraphQLObjectType,
8+
} from 'graphql-esm/type';
9+
10+
const queryType: GraphQLObjectType = new GraphQLObjectType({
11+
name: 'Query',
12+
fields: () => ({
13+
sayHi: {
14+
type: GraphQLString,
15+
args: {
16+
who: {
17+
type: GraphQLString,
18+
defaultValue: 'World',
19+
},
20+
},
21+
resolve(_root, args: { who: string }) {
22+
return 'Hello ' + args.who;
23+
},
24+
},
25+
}),
26+
});
27+
28+
const schema: GraphQLSchema = new GraphQLSchema({ query: queryType });
29+
30+
const result: ExecutionResult = graphqlSync({
31+
schema,
32+
source: `
33+
query helloWho($who: String){
34+
test(who: $who)
35+
}
36+
`,
37+
variableValues: { who: 'Dolly' },
38+
});

integrationTests/ts/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
},
77
"dependencies": {
88
"graphql": "file:../graphql.tgz",
9+
"graphql-esm": "file:../graphql-esm.tgz",
910
"typescript-4.1": "npm:[email protected]",
1011
"typescript-4.2": "npm:[email protected]",
1112
"typescript-4.3": "npm:[email protected]",

integrationTests/webpack-esm/package.json

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

integrationTests/webpack-esm/test.js

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

integrationTests/webpack-esm/webpack.config.json

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

integrationTests/webpack-esm/entry.js renamed to integrationTests/webpack/entry-esm.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// eslint-disable-next-line node/no-missing-import, import/no-unresolved
2-
import { buildSchema, graphqlSync } from 'graphql';
2+
import { graphqlSync } from 'graphql-esm';
3+
4+
// eslint-disable-next-line node/no-missing-import, import/no-unresolved
5+
import { buildSchema } from 'graphql-esm/utilities/buildASTSchema';
36

47
const schema = buildSchema('type Query { hello: String }');
58

integrationTests/webpack/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
},
77
"dependencies": {
88
"graphql": "file:../graphql.tgz",
9+
"graphql-esm": "file:../graphql-esm.tgz",
910
"webpack": "5.x.x",
1011
"webpack-cli": "4.x.x"
1112
}

0 commit comments

Comments
 (0)