-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
308 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
/node_modules | ||
/coverage | ||
/npmDist | ||
/npmEsmDist | ||
/denoDist | ||
/npm | ||
/deno | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ | |
/denoDist | ||
/npm | ||
/deno | ||
/npmEsmDist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* eslint-disable node/no-missing-import, import/no-unresolved, node/no-unsupported-features/es-syntax */ | ||
|
||
import { deepStrictEqual, strictEqual } from 'assert'; | ||
|
||
import { version } from 'version'; | ||
import { schema } from 'schema'; | ||
|
||
import { graphqlSync } from 'graphql'; | ||
|
||
// Import without explicit extension | ||
import { isPromise } from 'graphql/jsutils/isPromise'; | ||
|
||
// Import package.json | ||
import pkg from 'graphql/package.json'; | ||
|
||
deepStrictEqual(version, pkg.version); | ||
|
||
const result = graphqlSync({ | ||
schema, | ||
source: '{ hello }', | ||
rootValue: { hello: 'world' }, | ||
}); | ||
|
||
deepStrictEqual(result, { | ||
data: { | ||
__proto__: null, | ||
hello: 'world', | ||
}, | ||
}); | ||
|
||
strictEqual(isPromise(Promise.resolve()), true); | ||
|
||
// The possible promise rejection is handled by "--unhandled-rejections=strict" | ||
import('graphql/jsutils/isPromise').then((isPromisePkg) => { | ||
strictEqual(isPromisePkg.isPromise(Promise.resolve()), true); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"type": "module", | ||
"description": "graphql-js ESM should work on all supported node versions", | ||
"scripts": { | ||
"test": "node test.js" | ||
}, | ||
"dependencies": { | ||
"graphql": "file:../graphql-esm.tgz", | ||
"node-12": "npm:[email protected]", | ||
"node-14": "npm:[email protected]", | ||
"node-16": "npm:[email protected]", | ||
"schema": "file:./schema", | ||
"version": "file:./version" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "schema", | ||
"exports": { | ||
".": { | ||
"import": "./schema.mjs" | ||
} | ||
}, | ||
"peerDependencies": { | ||
"graphql": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { buildSchema } from 'graphql/utilities'; | ||
|
||
export const schema = buildSchema('type Query { hello: String }'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { execSync } from 'child_process'; | ||
import { readFileSync } from 'fs'; | ||
import { resolve } from 'path'; | ||
|
||
const { dependencies } = JSON.parse( | ||
readFileSync(resolve('package.json'), 'utf-8'), | ||
); | ||
|
||
const nodeVersions = Object.keys(dependencies) | ||
.filter((pkg) => pkg.startsWith('node-')) | ||
.sort((a, b) => b.localeCompare(a)); | ||
|
||
for (const version of nodeVersions) { | ||
console.log(`Testing on ${version} ...`); | ||
|
||
const nodePath = resolve('node_modules', version, 'bin/node'); | ||
execSync( | ||
nodePath + | ||
' --experimental-json-modules --unhandled-rejections=strict index.js', | ||
{ stdio: 'inherit' }, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "bar", | ||
"type": "module", | ||
"main": "./version.js", | ||
"peerDependencies": { | ||
"graphql": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* eslint-disable import/no-unresolved, node/no-missing-import */ | ||
|
||
import { version } from 'graphql'; | ||
|
||
export { version }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
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' }, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,11 @@ | |
}, | ||
"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]", | ||
"typescript-4.4": "npm:[email protected]" | ||
"typescript-4.4": "npm:[email protected]", | ||
"typescript-4.5": "npm:[email protected]" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// eslint-disable-next-line node/no-missing-import, import/no-unresolved | ||
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 }'); | ||
|
||
export const result = graphqlSync({ | ||
schema, | ||
source: '{ hello }', | ||
rootValue: { hello: 'world' }, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.