Skip to content

Commit 085c5f0

Browse files
committed
Merge remote-tracking branch 'upstream/main' into tsdoc-eslint
2 parents e5b2dfd + d82c8e2 commit 085c5f0

File tree

12 files changed

+931
-542
lines changed

12 files changed

+931
-542
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphql",
3-
"version": "16.0.0-alpha.2",
3+
"version": "16.0.0-alpha.3",
44
"description": "A Query Language and Runtime which can target any service.",
55
"license": "MIT",
66
"private": true,
@@ -25,7 +25,7 @@
2525
},
2626
"scripts": {
2727
"preversion": ". ./resources/checkgit.sh && npm ci",
28-
"version": "node resources/gen-version.js && npm test && git add src/version.js",
28+
"version": "node resources/gen-version.js && npm test && git add src/version.ts",
2929
"fuzzonly": "mocha --full-trace src/**/__tests__/**/*-fuzz.ts",
3030
"changelog": "node resources/gen-changelog.js",
3131
"benchmark": "node benchmark/benchmark.js",

resources/build-npm.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,17 @@ function buildPackageJSON() {
9090
const { preReleaseTag } = versionMatch.groups;
9191

9292
if (preReleaseTag != null) {
93-
const [tag] = preReleaseTag.split('.');
93+
const splittedTag = preReleaseTag.split('.');
94+
// Note: `experimental-*` take precedence over `alpha`, `beta` or `rc`.
95+
const publishTag = splittedTag[2] ?? splittedTag[0];
9496
assert(
95-
tag.startsWith('experimental-') || ['alpha', 'beta', 'rc'].includes(tag),
96-
`"${tag}" tag is supported.`,
97+
['alpha', 'beta', 'rc'].includes(publishTag) ||
98+
publishTag.startsWith('experimental-'),
99+
`"${publishTag}" tag is supported.`,
97100
);
98101

99102
assert(!packageJSON.publishConfig, 'Can not override "publishConfig".');
100-
packageJSON.publishConfig = { tag: tag || 'latest' };
103+
packageJSON.publishConfig = { tag: publishTag || 'latest' };
101104
}
102105

103106
return packageJSON;

src/__tests__/version-test.ts

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ import { describe, it } from 'mocha';
44
import { version, versionInfo } from '../version';
55

66
describe('Version', () => {
7-
it('version', () => {
8-
expect(version).to.be.a('string');
9-
expect(version).to.match(
10-
/^\d+\.\d+\.\d(-(alpha|beta|rc|(experimental-[\w-]+))\.\d+)?$/,
11-
);
12-
});
13-
147
it('versionInfo', () => {
158
expect(versionInfo).to.be.an('object');
169
expect(versionInfo).to.have.all.keys(
@@ -21,20 +14,38 @@ describe('Version', () => {
2114
);
2215

2316
const { major, minor, patch, preReleaseTag } = versionInfo;
24-
25-
expect(major).to.be.a('number');
26-
expect(minor).to.be.a('number');
27-
expect(patch).to.be.a('number');
17+
expect(major).to.be.a('number').at.least(0);
18+
expect(minor).to.be.a('number').at.least(0);
19+
expect(patch).to.be.a('number').at.least(0);
2820

2921
// istanbul ignore next (Can't be verified on all versions)
30-
if (preReleaseTag !== null) {
31-
expect(preReleaseTag).to.be.a('string');
22+
switch (preReleaseTag?.split('.').length) {
23+
case null:
24+
break;
25+
case 2:
26+
expect(preReleaseTag).to.match(
27+
/^(alpha|beta|rc|experimental-[\w-]+)\.\d+/,
28+
);
29+
break;
30+
case 4:
31+
expect(preReleaseTag).to.match(
32+
/^(alpha|beta|rc)\.\d+.experimental-[\w-]+\.\d+/,
33+
);
34+
break;
35+
default:
36+
expect.fail('Invalid pre-release tag: ' + preReleaseTag);
3237
}
38+
});
39+
40+
it('version', () => {
41+
expect(version).to.be.a('string');
3342

34-
expect(
35-
`${major}.${minor}.${patch}` +
36-
// istanbul ignore next (Can't be verified on all versions)
37-
(preReleaseTag !== null ? '-' + preReleaseTag : ''),
38-
).to.equal(version);
43+
const { major, minor, patch, preReleaseTag } = versionInfo;
44+
expect(version).to.equal(
45+
// istanbul ignore next (Can't be verified on all versions)
46+
preReleaseTag === null
47+
? `${major}.${minor}.${patch}`
48+
: `${major}.${minor}.${patch}-${preReleaseTag}`,
49+
);
3950
});
4051
});

src/execution/execute.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export interface ExecutionArgs {
142142
}
143143

144144
/**
145-
* Implements the "Evaluating requests" section of the GraphQL specification.
145+
* Implements the "Executing requests" section of the GraphQL specification.
146146
*
147147
* Returns either a synchronous ExecutionResult (if all encountered resolvers
148148
* are synchronous), or a Promise of an ExecutionResult that will eventually be
@@ -196,7 +196,7 @@ export function execute(args: ExecutionArgs): PromiseOrValue<ExecutionResult> {
196196
}
197197

198198
/**
199-
* Also implements the "Evaluating requests" section of the GraphQL specification.
199+
* Also implements the "Executing requests" section of the GraphQL specification.
200200
* However, it guarantees to complete synchronously (or throw an error) assuming
201201
* that all field resolvers are also synchronous.
202202
*/
@@ -327,7 +327,7 @@ export function buildExecutionContext(
327327
}
328328

329329
/**
330-
* Implements the "Evaluating operations" section of the spec.
330+
* Implements the "Executing operations" section of the spec.
331331
*/
332332
function executeOperation(
333333
exeContext: ExecutionContext,
@@ -367,8 +367,8 @@ function executeOperation(
367367
}
368368

369369
/**
370-
* Implements the "Evaluating selection sets" section of the spec
371-
* for "write" mode.
370+
* Implements the "Executing selection sets" section of the spec
371+
* for fields that must be executed serially.
372372
*/
373373
function executeFieldsSerially(
374374
exeContext: ExecutionContext,
@@ -381,7 +381,7 @@ function executeFieldsSerially(
381381
fields.entries(),
382382
(results, [responseName, fieldNodes]) => {
383383
const fieldPath = addPath(path, responseName, parentType.name);
384-
const result = resolveField(
384+
const result = executeField(
385385
exeContext,
386386
parentType,
387387
sourceValue,
@@ -405,8 +405,8 @@ function executeFieldsSerially(
405405
}
406406

407407
/**
408-
* Implements the "Evaluating selection sets" section of the spec
409-
* for "read" mode.
408+
* Implements the "Executing selection sets" section of the spec
409+
* for fields that may be executed in parallel.
410410
*/
411411
function executeFields(
412412
exeContext: ExecutionContext,
@@ -420,7 +420,7 @@ function executeFields(
420420

421421
for (const [responseName, fieldNodes] of fields.entries()) {
422422
const fieldPath = addPath(path, responseName, parentType.name);
423-
const result = resolveField(
423+
const result = executeField(
424424
exeContext,
425425
parentType,
426426
sourceValue,
@@ -583,12 +583,12 @@ function getFieldEntryKey(node: FieldNode): string {
583583
}
584584

585585
/**
586-
* Resolves the field on the given source object. In particular, this
587-
* figures out the value that the field returns by calling its resolve function,
588-
* then calls completeValue to complete promises, serialize scalars, or execute
589-
* the sub-selection-set for objects.
586+
* Implements the "Executing field" section of the spec
587+
* In particular, this function figures out the value that the field returns by
588+
* calling its resolve function, then calls completeValue to complete promises,
589+
* serialize scalars, or execute the sub-selection-set for objects.
590590
*/
591-
function resolveField(
591+
function executeField(
592592
exeContext: ExecutionContext,
593593
parentType: GraphQLObjectType,
594594
source: unknown,
@@ -722,7 +722,7 @@ function handleFieldError(
722722
* and then complete based on that type
723723
*
724724
* Otherwise, the field type expects a sub-selection set, and will complete the
725-
* value by evaluating all sub-selections.
725+
* value by executing all sub-selections.
726726
*/
727727
function completeValue(
728728
exeContext: ExecutionContext,

0 commit comments

Comments
 (0)