Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloSzx committed Nov 9, 2021
1 parent d295901 commit df33fc4
Show file tree
Hide file tree
Showing 19 changed files with 77 additions and 280 deletions.
2 changes: 0 additions & 2 deletions integrationTests/integration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ describe('Integration Tests', () => {
}

testOnNodeProject('ts');
testOnNodeProject('ts-esm');
testOnNodeProject('node');
testOnNodeProject('node-esm');
testOnNodeProject('webpack');
testOnNodeProject('webpack-esm');
});
18 changes: 11 additions & 7 deletions integrationTests/node-esm/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
/* eslint-disable node/no-missing-import, import/no-unresolved */

import { deepStrictEqual, strictEqual } from 'assert';
import { readFileSync } from 'fs';

// Regular import
import { graphqlSync } from 'graphql';
// import with explicit extension
// Import with explicit extension
import { version } from 'graphql/version.js';
// _/index.js import
import { buildSchema } from 'graphql/utilities';
// import without explicit extension
// Import without explicit extension
import { isPromise } from 'graphql/jsutils/isPromise';

deepStrictEqual(
version,
JSON.parse(readFileSync('./node_modules/graphql/package.json')).version,
);
// Import package.json
import pkg from 'graphql/package.json';

deepStrictEqual(version, pkg.version);

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

Expand All @@ -33,3 +32,8 @@ deepStrictEqual(result, {
});

strictEqual(isPromise(Promise.resolve()), true);

// The possible promise rejection is handled by "--unhandled-rejections=strict"
import('graphql/jsutils/isPromise').then(({ isPromise }) => {
strictEqual(isPromise(Promise.resolve()), true);
});
6 changes: 5 additions & 1 deletion integrationTests/node-esm/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ for (const version of nodeVersions) {
console.log(`Testing on ${version} ...`);

const nodePath = resolve('node_modules', version, 'bin/node');
execSync(nodePath + ' index.js', { stdio: 'inherit' });
execSync(
nodePath +
' --experimental-json-modules --unhandled-rejections=strict index.js',
{ stdio: 'inherit' },
);
}
72 changes: 0 additions & 72 deletions integrationTests/ts-esm/TypedQueryDocumentNode-test.ts

This file was deleted.

62 changes: 0 additions & 62 deletions integrationTests/ts-esm/extensions-test.ts

This file was deleted.

8 changes: 0 additions & 8 deletions integrationTests/ts-esm/internalImports-test.ts

This file was deleted.

14 changes: 0 additions & 14 deletions integrationTests/ts-esm/package.json

This file was deleted.

19 changes: 0 additions & 19 deletions integrationTests/ts-esm/test.js

This file was deleted.

11 changes: 0 additions & 11 deletions integrationTests/ts-esm/tsconfig.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
import type { ExecutionResult } from 'graphql/execution';

import { graphqlSync } from 'graphql';
import { GraphQLString, GraphQLSchema, GraphQLObjectType } from 'graphql/type';

const queryType: GraphQLObjectType = new GraphQLObjectType({
name: 'Query',
fields: () => ({
sayHi: {
type: GraphQLString,
args: {
who: {
type: GraphQLString,
defaultValue: 'World',
},
},
resolve(_root, args: { who: string }) {
return 'Hello ' + args.who;
},
},
}),
});

const schema: GraphQLSchema = new GraphQLSchema({ query: queryType });

const result: ExecutionResult = graphqlSync({
schema,
source: `
query helloWho($who: String){
test(who: $who)
}
`,
variableValues: { who: 'Dolly' },
});
import type { ExecutionResult } from 'graphql-esm/execution';

import { graphqlSync } from 'graphql-esm';
import {
GraphQLString,
GraphQLSchema,
GraphQLObjectType,
} from 'graphql-esm/type';

const queryType: GraphQLObjectType = new GraphQLObjectType({
name: 'Query',
fields: () => ({
sayHi: {
type: GraphQLString,
args: {
who: {
type: GraphQLString,
defaultValue: 'World',
},
},
resolve(_root, args: { who: string }) {
return 'Hello ' + args.who;
},
},
}),
});

const schema: GraphQLSchema = new GraphQLSchema({ query: queryType });

const result: ExecutionResult = graphqlSync({
schema,
source: `
query helloWho($who: String){
test(who: $who)
}
`,
variableValues: { who: 'Dolly' },
});
1 change: 1 addition & 0 deletions integrationTests/ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
},
"dependencies": {
"graphql": "file:../graphql.tgz",
"graphql-esm": "file:../graphql-esm.tgz",
"typescript-4.1": "npm:[email protected]",
"typescript-4.2": "npm:[email protected]",
"typescript-4.3": "npm:[email protected]",
Expand Down
13 changes: 0 additions & 13 deletions integrationTests/webpack-esm/package.json

This file was deleted.

12 changes: 0 additions & 12 deletions integrationTests/webpack-esm/test.js

This file was deleted.

12 changes: 0 additions & 12 deletions integrationTests/webpack-esm/webpack.config.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// eslint-disable-next-line node/no-missing-import, import/no-unresolved
import { buildSchema, graphqlSync } from 'graphql';
import { graphqlSync } from 'graphql-esm';

// eslint-disable-next-line node/no-missing-import, import/no-unresolved
import { buildSchema } from 'graphql-esm/utilities/buildASTSchema';

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

Expand Down
1 change: 1 addition & 0 deletions integrationTests/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
},
"dependencies": {
"graphql": "file:../graphql.tgz",
"graphql-esm": "file:../graphql-esm.tgz",
"webpack": "5.x.x",
"webpack-cli": "4.x.x"
}
Expand Down
Loading

0 comments on commit df33fc4

Please sign in to comment.