Skip to content

Commit

Permalink
Merge branch 'main' into abort-execution
Browse files Browse the repository at this point in the history
  • Loading branch information
igrlk committed Oct 2, 2023
2 parents 6fa5336 + 7a6d055 commit 01c64ac
Show file tree
Hide file tree
Showing 109 changed files with 8,858 additions and 17,639 deletions.
842 changes: 842 additions & 0 deletions .eslintrc.cjs

Large diffs are not rendered by default.

742 changes: 0 additions & 742 deletions .eslintrc.yml

This file was deleted.

7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ jobs:
- name: Install Dependencies
run: npm ci --ignore-scripts

# Disabled due to https://github.com/milesj/docusaurus-plugin-typedoc-api/pull/19
# - name: Check that package-lock.json doesn't have conflicts
# run: npm ls --depth 999
- name: Check that package-lock.json doesn't have conflicts
run: npm ls --depth 999

- name: Run npm install
run: npm install --ignore-scripts --force --package-lock-only --engine-strict --strict-peer-deps
Expand Down Expand Up @@ -146,7 +145,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node_version_to_setup: [14, 16, 18]
node_version_to_setup: [16, 18, 19]
permissions:
contents: read # for actions/checkout
steps:
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
v19
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,24 @@ through that README and the corresponding tests in parallel.

Install GraphQL.js from npm

With npm:
With `npm`:

```sh
npm install --save graphql
```

or using yarn:
With `yarn`:

```sh
yarn add graphql
```

With `bun`:

```sh
bun add graphql
```

GraphQL.js provides two important capabilities: building a type schema and
serving queries against that type schema.

Expand Down
13 changes: 13 additions & 0 deletions benchmark/repeated-fields-benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { graphqlSync } from 'graphql/graphql.js';
import { buildSchema } from 'graphql/utilities/buildASTSchema.js';

const schema = buildSchema('type Query { hello: String! }');
const source = `{ ${'hello '.repeat(250)}}`;

export const benchmark = {
name: 'Many repeated fields',
count: 5,
measure() {
graphqlSync({ schema, source });
},
};
32 changes: 30 additions & 2 deletions integrationTests/node/index.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
const assert = require('assert');
const { readFileSync } = require('fs');

const { graphqlSync } = require('graphql');
const {
experimentalExecuteIncrementally,
graphqlSync,
parse,
} = require('graphql');
const { buildSchema } = require('graphql/utilities');
const { version } = require('graphql/version');

Expand All @@ -12,7 +16,7 @@ assert.deepStrictEqual(

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

const result = graphqlSync({
let result = graphqlSync({
schema,
source: '{ hello }',
rootValue: { hello: 'world' },
Expand All @@ -24,3 +28,27 @@ assert.deepStrictEqual(result, {
hello: 'world',
},
});

/**
* The below test triggers a call `invariant` method during execution (by
* passing a negative number to the `initialCount` parameter on the `@stream`
* directive). This ensures that the `inlineInvariant` method called by our
* build script works correctly.
**/

const experimentalSchema = buildSchema(`
directive @stream(initialCount: Int!) on FIELD
type Query {
greetings: [String]
}
`);

result = experimentalExecuteIncrementally({
schema: experimentalSchema,
document: parse('{ greetings @stream(initialCount: -1) }'),
rootValue: { greetings: ['hi', 'hello'] },
});

assert(result.errors?.[0] !== undefined);
assert(!result.errors[0].message.includes('is not defined'));
32 changes: 30 additions & 2 deletions integrationTests/node/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
import assert from 'assert';
import { readFileSync } from 'fs';

import { graphqlSync } from 'graphql-esm';
import {
experimentalExecuteIncrementally,
graphqlSync,
parse,
} from 'graphql-esm';
import { buildSchema } from 'graphql-esm/utilities';
import { version } from 'graphql-esm/version';

Expand All @@ -13,7 +17,7 @@ assert.deepStrictEqual(

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

const result = graphqlSync({
let result = graphqlSync({
schema,
source: '{ hello }',
rootValue: { hello: 'world' },
Expand All @@ -25,3 +29,27 @@ assert.deepStrictEqual(result, {
hello: 'world',
},
});

/**
* The below test triggers a call `invariant` method during execution (by
* passing a negative number to the `initialCount` parameter on the `@stream`
* directive). This ensures that the `inlineInvariant` method called by our
* build script works correctly.
**/

const experimentalSchema = buildSchema(`
directive @stream(initialCount: Int!) on FIELD
type Query {
greetings: [String]
}
`);

result = experimentalExecuteIncrementally({
schema: experimentalSchema,
document: parse('{ greetings @stream(initialCount: -1) }'),
rootValue: { greetings: ['hi', 'hello'] },
});

assert(result.errors?.[0] !== undefined);
assert(!result.errors[0].message.includes('is not defined'));
3 changes: 2 additions & 1 deletion integrationTests/node/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ const graphqlPackageJSON = JSON.parse(
);

const nodeVersions = graphqlPackageJSON.engines.node
.replaceAll('^', '')
.replaceAll('>=', '')
.split(' || ')
.map((version) => version.replace('^', '').replace('>=', ''))
.sort((a, b) => b.localeCompare(a));

for (const version of nodeVersions) {
Expand Down
3 changes: 2 additions & 1 deletion integrationTests/ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"typescript-4.6": "npm:[email protected]",
"typescript-4.7": "npm:[email protected]",
"typescript-4.8": "npm:[email protected]",
"typescript-4.9": "npm:[email protected]"
"typescript-4.9": "npm:[email protected]",
"typescript-4.9": "npm:[email protected]"
}
}
2 changes: 2 additions & 0 deletions integrationTests/webpack/test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import assert from 'assert';

/* eslint-disable n/no-missing-import */
import cjs from './dist/main-cjs.cjs';
import mjs from './dist/main-mjs.cjs';
/* eslint-enable n/no-missing-import */

assert.deepStrictEqual(cjs.result, {
data: {
Expand Down
Loading

0 comments on commit 01c64ac

Please sign in to comment.