Skip to content

Commit fb24857

Browse files
remove iterall, update types/tests
1 parent 2f415ad commit fb24857

File tree

7 files changed

+54
-60
lines changed

7 files changed

+54
-60
lines changed

src/__tests__/starWarsDeferredQuery-test.js

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// @flow strict
22

3-
import { forAwaitEach } from 'iterall';
43
import { expect } from 'chai';
54
import { describe, it } from 'mocha';
65

@@ -89,9 +88,9 @@ describe('Star Wars Query Deferred Tests', () => {
8988

9089
/* istanbul ignore else */
9190
if (patchesIterable) {
92-
await forAwaitEach(patchesIterable, patch => {
91+
for await (const patch of patchesIterable) {
9392
patches.push(patch);
94-
});
93+
}
9594
}
9695

9796
expect(patches).to.have.lengthOf(1);
@@ -126,9 +125,9 @@ describe('Star Wars Query Deferred Tests', () => {
126125

127126
/* istanbul ignore else */
128127
if (patchesIterable) {
129-
await forAwaitEach(patchesIterable, patch => {
128+
for await (const patch of patchesIterable) {
130129
patches.push(patch);
131-
});
130+
}
132131
}
133132

134133
expect(patches).to.have.lengthOf(1);
@@ -181,9 +180,9 @@ describe('Star Wars Query Deferred Tests', () => {
181180

182181
/* istanbul ignore else */
183182
if (patchesIterable) {
184-
await forAwaitEach(patchesIterable, patch => {
183+
for await (const patch of patchesIterable) {
185184
patches.push(patch);
186-
});
185+
}
187186
}
188187

189188
expect(patches).to.have.lengthOf(2);
@@ -240,9 +239,9 @@ describe('Star Wars Query Deferred Tests', () => {
240239

241240
/* istanbul ignore else */
242241
if (patchesIterable) {
243-
await forAwaitEach(patchesIterable, patch => {
242+
for await (const patch of patchesIterable) {
244243
patches.push(patch);
245-
});
244+
}
246245
}
247246
expect(patches).to.have.lengthOf(1);
248247
expect(patches[0]).to.deep.equal({
@@ -331,9 +330,9 @@ describe('Star Wars Query Deferred Tests', () => {
331330

332331
/* istanbul ignore else */
333332
if (patchesIterable) {
334-
await forAwaitEach(patchesIterable, patch => {
333+
for await (const patch of patchesIterable) {
335334
patches.push(patch);
336-
});
335+
}
337336
}
338337

339338
expect(patches).to.have.lengthOf(2);
@@ -417,9 +416,9 @@ describe('Star Wars Query Deferred Tests', () => {
417416

418417
/* istanbul ignore else */
419418
if (patchesIterable) {
420-
await forAwaitEach(patchesIterable, patch => {
419+
for await (const patch of patchesIterable) {
421420
patches.push(patch);
422-
});
421+
}
423422
}
424423
expect(patches).to.have.lengthOf(1);
425424
expect(patches[0]).to.deep.equal({
@@ -468,9 +467,9 @@ describe('Star Wars Query Deferred Tests', () => {
468467

469468
/* istanbul ignore else */
470469
if (patchesIterable) {
471-
await forAwaitEach(patchesIterable, patch => {
470+
for await (const patch of patchesIterable) {
472471
patches.push(patch);
473-
});
472+
}
474473
}
475474
expect(patches).to.have.lengthOf(1);
476475
expect(patches[0]).to.deep.equal({
@@ -554,9 +553,9 @@ describe('Star Wars Query Deferred Tests', () => {
554553

555554
/* istanbul ignore else */
556555
if (patchesIterable) {
557-
await forAwaitEach(patchesIterable, patch => {
556+
for await (const patch of patchesIterable) {
558557
patches.push(patch);
559-
});
558+
}
560559
}
561560
expect(patches).to.have.lengthOf(1);
562561
expect(patches[0]).to.deep.equal({
@@ -600,9 +599,9 @@ describe('Star Wars Query Deferred Tests', () => {
600599

601600
/* istanbul ignore else */
602601
if (patchesIterable) {
603-
await forAwaitEach(patchesIterable, patch => {
602+
for await (const patch of patchesIterable) {
604603
patches.push(patch);
605-
});
604+
}
606605
}
607606
expect(patches).to.have.lengthOf(1);
608607
expect(patches[0]).to.deep.equal({

src/__tests__/starWarsStreamQuery-test.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// @flow strict
22

3-
import { forAwaitEach } from 'iterall';
43
import { expect } from 'chai';
54
import { describe, it } from 'mocha';
65

@@ -217,9 +216,9 @@ describe('Star Wars Query Stream Tests', () => {
217216

218217
/* istanbul ignore else */
219218
if (patchesIterable) {
220-
await forAwaitEach(patchesIterable, patch => {
219+
for await (const patch of patchesIterable) {
221220
patches.push(patch);
222-
});
221+
}
223222
}
224223
expect(patches).to.have.lengthOf(1);
225224
expect(patches[0]).to.deep.equal({
@@ -273,9 +272,9 @@ describe('Star Wars Query Stream Tests', () => {
273272

274273
/* istanbul ignore else */
275274
if (patchesIterable) {
276-
await forAwaitEach(patchesIterable, patch => {
275+
for await (const patch of patchesIterable) {
277276
patches.push(patch);
278-
});
277+
}
279278
}
280279
expect(patches).to.have.lengthOf(3);
281280
expect(patches[0]).to.deep.equal({
@@ -336,9 +335,9 @@ describe('Star Wars Query Stream Tests', () => {
336335

337336
/* istanbul ignore else */
338337
if (patchesIterable) {
339-
await forAwaitEach(patchesIterable, patch => {
338+
for await (const patch of patchesIterable) {
340339
patches.push(patch);
341-
});
340+
}
342341
}
343342

344343
expect(patches).to.have.lengthOf(1);
@@ -377,9 +376,9 @@ describe('Star Wars Query Stream Tests', () => {
377376

378377
/* istanbul ignore else */
379378
if (patchesIterable) {
380-
await forAwaitEach(patchesIterable, patch => {
379+
for await (const patch of patchesIterable) {
381380
patches.push(patch);
382-
});
381+
}
383382
}
384383

385384
expect(patches).to.have.lengthOf(3);

src/execution/dispatcher.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @flow strict
22

3-
import { $$asyncIterator } from 'iterall';
3+
import { SYMBOL_ASYNC_ITERATOR } from '../polyfills/symbols';
44

55
import { type Path, pathToArray } from '../jsutils/Path';
66
import { type PromiseOrValue } from '../jsutils/PromiseOrValue';
@@ -72,7 +72,7 @@ export class Dispatcher {
7272
next() {
7373
return getNext(results);
7474
},
75-
[$$asyncIterator]() {
75+
[SYMBOL_ASYNC_ITERATOR]() {
7676
return this;
7777
},
7878
}: any);

src/execution/execute.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import promiseReduce from '../jsutils/promiseReduce';
1616
import promiseForObject from '../jsutils/promiseForObject';
1717
import { type PromiseOrValue } from '../jsutils/PromiseOrValue';
1818
import { type Path, addPath, pathToArray } from '../jsutils/Path';
19-
import { Dispatcher, type ExecutionPatchResult } from './dispatcher';
2019

2120
import { GraphQLError } from '../error/GraphQLError';
2221
import { locatedError } from '../error/locatedError';
@@ -65,6 +64,8 @@ import {
6564
import { typeFromAST } from '../utilities/typeFromAST';
6665
import { getOperationRootType } from '../utilities/getOperationRootType';
6766

67+
import { Dispatcher, type ExecutionPatchResult } from './dispatcher';
68+
6869
import {
6970
getVariableValues,
7071
getArgumentValues,
@@ -548,9 +549,10 @@ export function collectFields(
548549
continue;
549550
}
550551

551-
const patchLabel = exeContext.schema.__experimentalDefer
552-
? getDeferredNodeLabel(exeContext, selection)
553-
: '';
552+
const patchLabel =
553+
exeContext.schema.__experimentalDefer === true
554+
? getDeferredNodeLabel(exeContext, selection)
555+
: '';
554556

555557
if (patchLabel) {
556558
const { fields: patchFields } = collectFields(
@@ -584,9 +586,10 @@ export function collectFields(
584586
continue;
585587
}
586588

587-
const patchLabel = exeContext.schema.__experimentalDefer
588-
? getDeferredNodeLabel(exeContext, selection)
589-
: '';
589+
const patchLabel =
590+
exeContext.schema.__experimentalDefer === true
591+
? getDeferredNodeLabel(exeContext, selection)
592+
: '';
590593

591594
if (
592595
visitedFragmentNames[fragName] &&
@@ -1083,7 +1086,7 @@ function completeListValue(
10831086
// since from here on it is not ever accessed by resolver functions.
10841087
const fieldPath = addPath(path, index);
10851088
if (
1086-
exeContext.schema.__experimentalStream &&
1089+
exeContext.schema.__experimentalStream === true &&
10871090
stream &&
10881091
stream.if !== false &&
10891092
typeof stream.label === 'string' &&
@@ -1120,11 +1123,10 @@ function completeListValue(
11201123
if (!containsPromise && isPromise(completedItem)) {
11211124
containsPromise = true;
11221125
}
1123-
}
1124-
1125-
return completedItem;
1126-
});
11271126

1127+
return completedItem;
1128+
}
1129+
}).filter(val => val !== undefined);
11281130
return containsPromise ? Promise.all(completedResults) : completedResults;
11291131
}
11301132

src/type/schema.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,16 @@ export class GraphQLSchema {
172172
// Provide specified directives (e.g. @include and @skip) by default.
173173
this._directives = config.directives || specifiedDirectives;
174174

175+
if (config.experimentalDefer === true) {
176+
this.__experimentalDefer = true;
177+
this._directives = [].concat(this._directives, [GraphQLDeferDirective]);
178+
}
179+
180+
if (config.experimentalStream === true) {
181+
this.__experimentalStream = true;
182+
this._directives = [].concat(this._directives, [GraphQLStreamDirective]);
183+
}
184+
175185
// To preserve order of user-provided types, we add first to add them to
176186
// the set of "collected" types, so `collectReferencedTypes` ignore them.
177187
const allReferencedTypes: Set<GraphQLNamedType> = new Set(config.types);
@@ -184,16 +194,6 @@ export class GraphQLSchema {
184194
}
185195
}
186196

187-
if (config.experimentalDefer) {
188-
this.__experimentalDefer = true;
189-
this._directives = [].concat(this._directives, [GraphQLDeferDirective]);
190-
}
191-
192-
if (config.experimentalStream) {
193-
this.__experimentalStream = true;
194-
this._directives = [].concat(this._directives, [GraphQLStreamDirective]);
195-
}
196-
197197
if (this._queryType != null) {
198198
collectReferencedTypes(this._queryType, allReferencedTypes);
199199
}

src/utilities/__tests__/schemaPrinter-test.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -922,12 +922,6 @@ describe('Type System Printer', () => {
922922
deprecationReason: String
923923
}
924924
925-
# Marks an element of a GraphQL schema as no longer supported.
926-
directive @deprecated(
927-
# Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).
928-
reason: String = "No longer supported"
929-
) on FIELD_DEFINITION | ENUM_VALUE
930-
931925
# A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.
932926
#
933927
# In some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.

src/utilities/buildASTSchema.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,15 @@ export function buildASTSchema(
109109

110110
if (
111111
options &&
112-
options.experimentalDefer &&
112+
options.experimentalDefer === true &&
113113
!directives.some(directive => directive.name === 'defer')
114114
) {
115115
directives.push(GraphQLDeferDirective);
116116
}
117117

118118
if (
119119
options &&
120-
options.experimentalStream &&
120+
options.experimentalStream === true &&
121121
!directives.some(directive => directive.name === 'stream')
122122
) {
123123
directives.push(GraphQLStreamDirective);

0 commit comments

Comments
 (0)