-
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
5 changed files
with
86 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { deepStrictEqual, strictEqual } from 'assert'; | ||
import { readFileSync } from 'fs'; | ||
|
||
// Regular import | ||
import { graphqlSync } from 'graphql'; | ||
// import with explicit extension | ||
import { version } from 'graphql/version.js'; | ||
// _/index.js import | ||
import { buildSchema } from 'graphql/utilities'; | ||
// import without explicit extension | ||
import { isPromise } from 'graphql/jsutils/isPromise'; | ||
|
||
deepStrictEqual( | ||
version, | ||
JSON.parse(readFileSync('./node_modules/graphql/package.json')).version, | ||
); | ||
|
||
const schema = buildSchema('type Query { hello: String }'); | ||
|
||
const result = graphqlSync({ | ||
schema, | ||
source: '{ hello }', | ||
rootValue: { hello: 'world' }, | ||
}); | ||
|
||
deepStrictEqual(result, { | ||
data: { | ||
__proto__: null, | ||
hello: 'world', | ||
}, | ||
}); | ||
|
||
strictEqual(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,13 @@ | ||
{ | ||
"type": "module", | ||
"description": "graphql-js should work on all supported node versions with ESM", | ||
"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]" | ||
} | ||
} |
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 { createRequire } from 'module'; | ||
import { dirname, join } from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
const { dependencies } = createRequire(import.meta.url)('./package.json'); | ||
|
||
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 = join( | ||
dirname(fileURLToPath(import.meta.url)), | ||
'node_modules', | ||
version, | ||
'bin/node', | ||
); | ||
execSync(nodePath + ' 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