Skip to content

Commit 778f2bb

Browse files
committed
wrapList
1 parent e236ca2 commit 778f2bb

27 files changed

+211
-196
lines changed

src/__tests__/starWarsSchema.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
GraphQLEnumType,
1212
GraphQLInterfaceType,
1313
GraphQLObjectType,
14-
GraphQLList,
1514
GraphQLNonNull,
1615
GraphQLSchema,
1716
GraphQLString,
@@ -118,12 +117,12 @@ const characterInterface = new GraphQLInterfaceType({
118117
description: 'The name of the character.',
119118
},
120119
friends: {
121-
type: new GraphQLList(characterInterface),
120+
type: characterInterface.wrapList(),
122121
description: 'The friends of the character, or an empty list if they ' +
123122
'have none.',
124123
},
125124
appearsIn: {
126-
type: new GraphQLList(episodeEnum),
125+
type: episodeEnum.wrapList(),
127126
description: 'Which movies they appear in.',
128127
},
129128
secretBackstory: {
@@ -166,13 +165,13 @@ const humanType = new GraphQLObjectType({
166165
description: 'The name of the human.',
167166
},
168167
friends: {
169-
type: new GraphQLList(characterInterface),
168+
type: characterInterface.wrapList(),
170169
description:
171170
'The friends of the human, or an empty list if they have none.',
172171
resolve: human => getFriends(human),
173172
},
174173
appearsIn: {
175-
type: new GraphQLList(episodeEnum),
174+
type: episodeEnum.wrapList(),
176175
description: 'Which movies they appear in.',
177176
},
178177
homePlanet: {
@@ -216,13 +215,13 @@ const droidType = new GraphQLObjectType({
216215
description: 'The name of the droid.',
217216
},
218217
friends: {
219-
type: new GraphQLList(characterInterface),
218+
type: characterInterface.wrapList(),
220219
description:
221220
'The friends of the droid, or an empty list if they have none.',
222221
resolve: droid => getFriends(droid),
223222
},
224223
appearsIn: {
225-
type: new GraphQLList(episodeEnum),
224+
type: episodeEnum.wrapList(),
226225
description: 'Which movies they appear in.',
227226
},
228227
secretBackstory: {

src/execution/__tests__/abstract-promise-test.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
GraphQLObjectType,
1414
GraphQLInterfaceType,
1515
GraphQLUnionType,
16-
GraphQLList,
1716
GraphQLString,
1817
GraphQLBoolean,
1918
} from '../../';
@@ -73,7 +72,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
7372
name: 'Query',
7473
fields: {
7574
pets: {
76-
type: new GraphQLList(PetType),
75+
type: PetType.wrapList(),
7776
resolve() {
7877
return [ new Dog('Odie', true), new Cat('Garfield', false) ];
7978
}
@@ -140,7 +139,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
140139
name: 'Query',
141140
fields: {
142141
pets: {
143-
type: new GraphQLList(PetType),
142+
type: PetType.wrapList(),
144143
resolve() {
145144
return [ new Dog('Odie', true), new Cat('Garfield', false) ];
146145
}
@@ -212,7 +211,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
212211
name: 'Query',
213212
fields: {
214213
pets: {
215-
type: new GraphQLList(PetType),
214+
type: PetType.wrapList(),
216215
resolve() {
217216
return [ new Dog('Odie', true), new Cat('Garfield', false) ];
218217
}
@@ -290,7 +289,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
290289
name: 'Query',
291290
fields: {
292291
pets: {
293-
type: new GraphQLList(PetType),
292+
type: PetType.wrapList(),
294293
resolve() {
295294
return Promise.resolve([
296295
new Dog('Odie', true),
@@ -380,7 +379,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
380379
name: 'Query',
381380
fields: {
382381
pets: {
383-
type: new GraphQLList(PetType),
382+
type: PetType.wrapList(),
384383
resolve() {
385384
return [
386385
new Dog('Odie', true),
@@ -465,7 +464,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
465464
name: 'Query',
466465
fields: {
467466
pets: {
468-
type: new GraphQLList(PetType),
467+
type: PetType.wrapList(),
469468
resolve() {
470469
return [
471470
new Dog('Odie', true),
@@ -536,7 +535,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
536535
name: 'Query',
537536
fields: {
538537
pets: {
539-
type: new GraphQLList(PetType),
538+
type: PetType.wrapList(),
540539
resolve() {
541540
return [
542541
new Dog('Odie', true),

src/execution/__tests__/abstract-test.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
GraphQLObjectType,
1414
GraphQLInterfaceType,
1515
GraphQLUnionType,
16-
GraphQLList,
1716
GraphQLString,
1817
GraphQLBoolean,
1918
} from '../../';
@@ -73,7 +72,7 @@ describe('Execute: Handles execution of abstract types', () => {
7372
name: 'Query',
7473
fields: {
7574
pets: {
76-
type: new GraphQLList(PetType),
75+
type: PetType.wrapList(),
7776
resolve() {
7877
return [ new Dog('Odie', true), new Cat('Garfield', false) ];
7978
}
@@ -136,7 +135,7 @@ describe('Execute: Handles execution of abstract types', () => {
136135
name: 'Query',
137136
fields: {
138137
pets: {
139-
type: new GraphQLList(PetType),
138+
type: PetType.wrapList(),
140139
resolve() {
141140
return [ new Dog('Odie', true), new Cat('Garfield', false) ];
142141
}
@@ -214,7 +213,7 @@ describe('Execute: Handles execution of abstract types', () => {
214213
name: 'Query',
215214
fields: {
216215
pets: {
217-
type: new GraphQLList(PetType),
216+
type: PetType.wrapList(),
218217
resolve() {
219218
return [
220219
new Dog('Odie', true),
@@ -304,7 +303,7 @@ describe('Execute: Handles execution of abstract types', () => {
304303
name: 'Query',
305304
fields: {
306305
pets: {
307-
type: new GraphQLList(PetType),
306+
type: PetType.wrapList(),
308307
resolve() {
309308
return [
310309
new Dog('Odie', true),
@@ -389,7 +388,7 @@ describe('Execute: Handles execution of abstract types', () => {
389388
name: 'Query',
390389
fields: {
391390
pets: {
392-
type: new GraphQLList(PetType),
391+
type: PetType.wrapList(),
393392
resolve() {
394393
return [
395394
new Dog('Odie', true),

src/execution/__tests__/executor-test.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { parse } from '../../language';
1313
import {
1414
GraphQLSchema,
1515
GraphQLObjectType,
16-
GraphQLList,
1716
GraphQLBoolean,
1817
GraphQLInt,
1918
GraphQLString,
@@ -180,8 +179,8 @@ describe('Execute: Handles basic execution tasks', () => {
180179
fields: {
181180
a: { type: GraphQLString },
182181
b: { type: GraphQLString },
183-
c: { type: new GraphQLList(GraphQLString) },
184-
deeper: { type: new GraphQLList(DataType) },
182+
c: { type: GraphQLString.wrapList() },
183+
deeper: { type: DataType.wrapList() },
185184
}
186185
});
187186

@@ -425,7 +424,7 @@ describe('Execute: Handles basic execution tasks', () => {
425424
syncError: { type: GraphQLString },
426425
syncRawError: { type: GraphQLString },
427426
syncReturnError: { type: GraphQLString },
428-
syncReturnErrorList: { type: new GraphQLList(GraphQLString) },
427+
syncReturnErrorList: { type: GraphQLString.wrapList() },
429428
async: { type: GraphQLString },
430429
asyncReject: { type: GraphQLString },
431430
asyncRawReject: { type: GraphQLString },
@@ -938,7 +937,7 @@ describe('Execute: Handles basic execution tasks', () => {
938937
name: 'Query',
939938
fields: {
940939
specials: {
941-
type: new GraphQLList(SpecialType),
940+
type: SpecialType.wrapList(),
942941
resolve: rootValue => rootValue.specials
943942
}
944943
}

src/execution/__tests__/lists-test.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
GraphQLObjectType,
1919
GraphQLString,
2020
GraphQLInt,
21-
GraphQLList,
2221
GraphQLNonNull
2322
} from '../../type';
2423

@@ -69,7 +68,7 @@ function check(testType, testData, expected) {
6968
describe('Execute: Accepts any iterable as list value', () => {
7069

7170
it('Accepts a Set as a List value', check(
72-
new GraphQLList(GraphQLString),
71+
GraphQLString.wrapList(),
7372
new Set([ 'apple', 'banana', 'apple', 'coconut' ]),
7473
{ data: { nest: { test: [ 'apple', 'banana', 'coconut' ] } } }
7574
));
@@ -81,7 +80,7 @@ describe('Execute: Accepts any iterable as list value', () => {
8180
}
8281

8382
it('Accepts an Generator function as a List value', check(
84-
new GraphQLList(GraphQLString),
83+
GraphQLString.wrapList(),
8584
yieldItems(),
8685
{ data: { nest: { test: [ 'one', '2', 'true' ] } } }
8786
));
@@ -91,13 +90,13 @@ describe('Execute: Accepts any iterable as list value', () => {
9190
}
9291

9392
it('Accepts function arguments as a List value', check(
94-
new GraphQLList(GraphQLString),
93+
GraphQLString.wrapList(),
9594
getArgs('one', 'two'),
9695
{ data: { nest: { test: [ 'one', 'two' ] } } }
9796
));
9897

9998
it('Does not accept (Iterable) String-literal as a List value', check(
100-
new GraphQLList(GraphQLString),
99+
GraphQLString.wrapList(),
101100
'Singluar',
102101
{ data: { nest: { test: null } },
103102
errors: [ {
@@ -112,7 +111,7 @@ describe('Execute: Accepts any iterable as list value', () => {
112111
describe('Execute: Handles list nullability', () => {
113112

114113
describe('[T]', () => {
115-
const type = new GraphQLList(GraphQLInt);
114+
const type = GraphQLInt.wrapList();
116115

117116
describe('Array<T>', () => {
118117

@@ -190,7 +189,7 @@ describe('Execute: Handles list nullability', () => {
190189
});
191190

192191
describe('[T]!', () => {
193-
const type = new GraphQLNonNull(new GraphQLList(GraphQLInt));
192+
const type = new GraphQLNonNull(GraphQLInt.wrapList());
194193

195194
describe('Array<T>', () => {
196195

@@ -277,7 +276,7 @@ describe('Execute: Handles list nullability', () => {
277276
});
278277

279278
describe('[T!]', () => {
280-
const type = new GraphQLList(new GraphQLNonNull(GraphQLInt));
279+
const type = (new GraphQLNonNull(GraphQLInt)).wrapList();
281280

282281
describe('Array<T>', () => {
283282

@@ -370,7 +369,7 @@ describe('Execute: Handles list nullability', () => {
370369

371370
describe('[T!]!', () => {
372371
const type =
373-
new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(GraphQLInt)));
372+
new GraphQLNonNull((new GraphQLNonNull(GraphQLInt)).wrapList());
374373

375374
describe('Array<T>', () => {
376375

src/execution/__tests__/schema-test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { parse } from '../../language';
1313
import {
1414
GraphQLSchema,
1515
GraphQLObjectType,
16-
GraphQLList,
1716
GraphQLNonNull,
1817
GraphQLInt,
1918
GraphQLString,
@@ -56,7 +55,7 @@ describe('Execute: Handles execution with a complex schema', () => {
5655
author: { type: BlogAuthor },
5756
title: { type: GraphQLString },
5857
body: { type: GraphQLString },
59-
keywords: { type: new GraphQLList(GraphQLString) }
58+
keywords: { type: GraphQLString.wrapList() }
6059
}
6160
});
6261

@@ -69,7 +68,7 @@ describe('Execute: Handles execution with a complex schema', () => {
6968
resolve: (_, { id }) => article(id)
7069
},
7170
feed: {
72-
type: new GraphQLList(BlogArticle),
71+
type: BlogArticle.wrapList(),
7372
resolve: () => [
7473
article(1),
7574
article(2),

src/execution/__tests__/union-interface-test.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
GraphQLObjectType,
1616
GraphQLInterfaceType,
1717
GraphQLUnionType,
18-
GraphQLList,
1918
GraphQLString,
2019
GraphQLBoolean
2120
} from '../../type';
@@ -88,8 +87,8 @@ const PersonType = new GraphQLObjectType({
8887
interfaces: [ NamedType ],
8988
fields: {
9089
name: { type: GraphQLString },
91-
pets: { type: new GraphQLList(PetType) },
92-
friends: { type: new GraphQLList(NamedType) },
90+
pets: { type: PetType.wrapList() },
91+
friends: { type: NamedType.wrapList() },
9392
},
9493
isTypeOf: value => value instanceof Person
9594
});
@@ -369,7 +368,7 @@ describe('Execute: Union and intersection types', () => {
369368
interfaces: [ NamedType2 ],
370369
fields: {
371370
name: { type: GraphQLString },
372-
friends: { type: new GraphQLList(NamedType2) },
371+
friends: { type: NamedType2.wrapList() },
373372
},
374373
});
375374

src/execution/__tests__/variables-test.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
GraphQLSchema,
1818
GraphQLObjectType,
1919
GraphQLInputObjectType,
20-
GraphQLList,
2120
GraphQLString,
2221
GraphQLNonNull,
2322
GraphQLScalarType
@@ -49,7 +48,7 @@ const TestInputObject = new GraphQLInputObjectType({
4948
name: 'TestInputObject',
5049
fields: {
5150
a: { type: GraphQLString },
52-
b: { type: new GraphQLList(GraphQLString) },
51+
b: { type: GraphQLString.wrapList() },
5352
c: { type: new GraphQLNonNull(GraphQLString) },
5453
d: { type: TestComplexScalar },
5554
}
@@ -97,23 +96,23 @@ const TestType = new GraphQLObjectType({
9796
},
9897
list: {
9998
type: GraphQLString,
100-
args: { input: { type: new GraphQLList(GraphQLString) } },
99+
args: { input: { type: GraphQLString.wrapList() } },
101100
resolve: (_, { input }) => input && JSON.stringify(input)
102101
},
103102
nnList: {
104103
type: GraphQLString,
105-
args: { input: { type: new GraphQLNonNull(new GraphQLList(GraphQLString)) } },
104+
args: { input: { type: new GraphQLNonNull(GraphQLString.wrapList()) } },
106105
resolve: (_, { input }) => input && JSON.stringify(input)
107106
},
108107
listNN: {
109108
type: GraphQLString,
110-
args: { input: { type: new GraphQLList(new GraphQLNonNull(GraphQLString)) } },
109+
args: { input: { type: (new GraphQLNonNull(GraphQLString)).wrapList() } },
111110
resolve: (_, { input }) => input && JSON.stringify(input)
112111
},
113112
nnListNN: {
114113
type: GraphQLString,
115114
args: { input: { type:
116-
new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(GraphQLString)))
115+
new GraphQLNonNull((new GraphQLNonNull(GraphQLString)).wrapList())
117116
} },
118117
resolve: (_, { input }) => input && JSON.stringify(input)
119118
},

0 commit comments

Comments
 (0)