Skip to content

Commit db57982

Browse files
Switch all code to create GraphQLList/GraphQLNonNull instances with new (#2761)
1 parent 388cc9a commit db57982

25 files changed

+284
-236
lines changed

src/__tests__/starWarsSchema.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,20 @@ const characterInterface = new GraphQLInterfaceType({
103103
description: 'A character in the Star Wars Trilogy',
104104
fields: () => ({
105105
id: {
106-
type: GraphQLNonNull(GraphQLString),
106+
type: new GraphQLNonNull(GraphQLString),
107107
description: 'The id of the character.',
108108
},
109109
name: {
110110
type: GraphQLString,
111111
description: 'The name of the character.',
112112
},
113113
friends: {
114-
type: GraphQLList(characterInterface),
114+
type: new GraphQLList(characterInterface),
115115
description:
116116
'The friends of the character, or an empty list if they have none.',
117117
},
118118
appearsIn: {
119-
type: GraphQLList(episodeEnum),
119+
type: new GraphQLList(episodeEnum),
120120
description: 'Which movies they appear in.',
121121
},
122122
secretBackstory: {
@@ -155,21 +155,21 @@ const humanType = new GraphQLObjectType({
155155
description: 'A humanoid creature in the Star Wars universe.',
156156
fields: () => ({
157157
id: {
158-
type: GraphQLNonNull(GraphQLString),
158+
type: new GraphQLNonNull(GraphQLString),
159159
description: 'The id of the human.',
160160
},
161161
name: {
162162
type: GraphQLString,
163163
description: 'The name of the human.',
164164
},
165165
friends: {
166-
type: GraphQLList(characterInterface),
166+
type: new GraphQLList(characterInterface),
167167
description:
168168
'The friends of the human, or an empty list if they have none.',
169169
resolve: (human) => getFriends(human),
170170
},
171171
appearsIn: {
172-
type: GraphQLList(episodeEnum),
172+
type: new GraphQLList(episodeEnum),
173173
description: 'Which movies they appear in.',
174174
},
175175
homePlanet: {
@@ -205,21 +205,21 @@ const droidType = new GraphQLObjectType({
205205
description: 'A mechanical creature in the Star Wars universe.',
206206
fields: () => ({
207207
id: {
208-
type: GraphQLNonNull(GraphQLString),
208+
type: new GraphQLNonNull(GraphQLString),
209209
description: 'The id of the droid.',
210210
},
211211
name: {
212212
type: GraphQLString,
213213
description: 'The name of the droid.',
214214
},
215215
friends: {
216-
type: GraphQLList(characterInterface),
216+
type: new GraphQLList(characterInterface),
217217
description:
218218
'The friends of the droid, or an empty list if they have none.',
219219
resolve: (droid) => getFriends(droid),
220220
},
221221
appearsIn: {
222-
type: GraphQLList(episodeEnum),
222+
type: new GraphQLList(episodeEnum),
223223
description: 'Which movies they appear in.',
224224
},
225225
secretBackstory: {
@@ -270,7 +270,7 @@ const queryType = new GraphQLObjectType({
270270
args: {
271271
id: {
272272
description: 'id of the human',
273-
type: GraphQLNonNull(GraphQLString),
273+
type: new GraphQLNonNull(GraphQLString),
274274
},
275275
},
276276
resolve: (_source, { id }) => getHuman(id),
@@ -280,7 +280,7 @@ const queryType = new GraphQLObjectType({
280280
args: {
281281
id: {
282282
description: 'id of the droid',
283-
type: GraphQLNonNull(GraphQLString),
283+
type: new GraphQLNonNull(GraphQLString),
284284
},
285285
},
286286
resolve: (_source, { id }) => getDroid(id),

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
7676
name: 'Query',
7777
fields: {
7878
pets: {
79-
type: GraphQLList(PetType),
79+
type: new GraphQLList(PetType),
8080
resolve() {
8181
return [new Dog('Odie', true), new Cat('Garfield', false)];
8282
},
@@ -150,7 +150,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
150150
name: 'Query',
151151
fields: {
152152
pets: {
153-
type: GraphQLList(PetType),
153+
type: new GraphQLList(PetType),
154154
resolve() {
155155
return [new Dog('Odie', true), new Cat('Garfield', false)];
156156
},
@@ -223,7 +223,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
223223
name: 'Query',
224224
fields: {
225225
pets: {
226-
type: GraphQLList(PetType),
226+
type: new GraphQLList(PetType),
227227
resolve() {
228228
return [new Dog('Odie', true), new Cat('Garfield', false)];
229229
},
@@ -317,7 +317,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
317317
name: 'Query',
318318
fields: {
319319
pets: {
320-
type: GraphQLList(PetType),
320+
type: new GraphQLList(PetType),
321321
resolve() {
322322
return Promise.resolve([
323323
new Dog('Odie', true),
@@ -420,7 +420,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
420420
name: 'Query',
421421
fields: {
422422
pets: {
423-
type: GraphQLList(PetType),
423+
type: new GraphQLList(PetType),
424424
resolve() {
425425
return [
426426
new Dog('Odie', true),
@@ -517,7 +517,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
517517
name: 'Query',
518518
fields: {
519519
pets: {
520-
type: GraphQLList(PetType),
520+
type: new GraphQLList(PetType),
521521
resolve() {
522522
return [new Dog('Odie', true), new Cat('Garfield', false)];
523523
},
@@ -590,7 +590,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
590590
name: 'Query',
591591
fields: {
592592
pets: {
593-
type: GraphQLList(PetType),
593+
type: new GraphQLList(PetType),
594594
resolve() {
595595
return [new Dog('Odie', true), new Cat('Garfield', false)];
596596
},

src/execution/__tests__/abstract-test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe('Execute: Handles execution of abstract types', () => {
7878
name: 'Query',
7979
fields: {
8080
pets: {
81-
type: GraphQLList(PetType),
81+
type: new GraphQLList(PetType),
8282
resolve() {
8383
return [new Dog('Odie', true), new Cat('Garfield', false)];
8484
},
@@ -147,7 +147,7 @@ describe('Execute: Handles execution of abstract types', () => {
147147
name: 'Query',
148148
fields: {
149149
pets: {
150-
type: GraphQLList(PetType),
150+
type: new GraphQLList(PetType),
151151
resolve() {
152152
return [new Dog('Odie', true), new Cat('Garfield', false)];
153153
},
@@ -238,7 +238,7 @@ describe('Execute: Handles execution of abstract types', () => {
238238
name: 'Query',
239239
fields: {
240240
pets: {
241-
type: GraphQLList(PetType),
241+
type: new GraphQLList(PetType),
242242
resolve() {
243243
return [
244244
new Dog('Odie', true),
@@ -342,7 +342,7 @@ describe('Execute: Handles execution of abstract types', () => {
342342
name: 'Query',
343343
fields: {
344344
pets: {
345-
type: GraphQLList(PetType),
345+
type: new GraphQLList(PetType),
346346
resolve() {
347347
return [
348348
new Dog('Odie', true),
@@ -524,7 +524,7 @@ describe('Execute: Handles execution of abstract types', () => {
524524
name: 'Query',
525525
fields: {
526526
pets: {
527-
type: GraphQLList(PetType),
527+
type: new GraphQLList(PetType),
528528
resolve() {
529529
return [new Dog('Odie', true), new Cat('Garfield', false)];
530530
},

src/execution/__tests__/executor-test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ describe('Execute: Handles basic execution tasks', () => {
146146
fields: {
147147
a: { type: GraphQLString },
148148
b: { type: GraphQLString },
149-
c: { type: GraphQLList(GraphQLString) },
150-
deeper: { type: GraphQLList(DataType) },
149+
c: { type: new GraphQLList(GraphQLString) },
150+
deeper: { type: new GraphQLList(DataType) },
151151
},
152152
});
153153

@@ -431,7 +431,7 @@ describe('Execute: Handles basic execution tasks', () => {
431431
syncError: { type: GraphQLString },
432432
syncRawError: { type: GraphQLString },
433433
syncReturnError: { type: GraphQLString },
434-
syncReturnErrorList: { type: GraphQLList(GraphQLString) },
434+
syncReturnErrorList: { type: new GraphQLList(GraphQLString) },
435435
async: { type: GraphQLString },
436436
asyncReject: { type: GraphQLString },
437437
asyncRejectWithExtensions: { type: GraphQLString },
@@ -612,7 +612,7 @@ describe('Execute: Handles basic execution tasks', () => {
612612
name: 'Query',
613613
fields: {
614614
foods: {
615-
type: GraphQLList(
615+
type: new GraphQLList(
616616
new GraphQLObjectType({
617617
name: 'Food',
618618
fields: {
@@ -659,11 +659,11 @@ describe('Execute: Handles basic execution tasks', () => {
659659
resolve: () => ({}),
660660
},
661661
nonNullA: {
662-
type: GraphQLNonNull(A),
662+
type: new GraphQLNonNull(A),
663663
resolve: () => ({}),
664664
},
665665
throws: {
666-
type: GraphQLNonNull(GraphQLString),
666+
type: new GraphQLNonNull(GraphQLString),
667667
resolve: () => {
668668
throw new Error('Catch me if you can');
669669
},
@@ -1090,7 +1090,7 @@ describe('Execute: Handles basic execution tasks', () => {
10901090
query: new GraphQLObjectType({
10911091
name: 'Query',
10921092
fields: {
1093-
specials: { type: GraphQLList(SpecialType) },
1093+
specials: { type: new GraphQLList(SpecialType) },
10941094
},
10951095
}),
10961096
});

src/execution/__tests__/nonnull-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ describe('Execute: handles non-nullable types', () => {
531531
type: GraphQLString,
532532
args: {
533533
cannotBeNull: {
534-
type: GraphQLNonNull(GraphQLString),
534+
type: new GraphQLNonNull(GraphQLString),
535535
},
536536
},
537537
resolve: (_, args) => 'Passed: ' + String(args.cannotBeNull),

src/execution/__tests__/schema-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ describe('Execute: Handles execution with a complex schema', () => {
4646
const BlogArticle = new GraphQLObjectType({
4747
name: 'Article',
4848
fields: {
49-
id: { type: GraphQLNonNull(GraphQLString) },
49+
id: { type: new GraphQLNonNull(GraphQLString) },
5050
isPublished: { type: GraphQLBoolean },
5151
author: { type: BlogAuthor },
5252
title: { type: GraphQLString },
5353
body: { type: GraphQLString },
54-
keywords: { type: GraphQLList(GraphQLString) },
54+
keywords: { type: new GraphQLList(GraphQLString) },
5555
},
5656
});
5757

@@ -64,7 +64,7 @@ describe('Execute: Handles execution with a complex schema', () => {
6464
resolve: (_, { id }) => article(id),
6565
},
6666
feed: {
67-
type: GraphQLList(BlogArticle),
67+
type: new GraphQLList(BlogArticle),
6868
resolve: () => [
6969
article(1),
7070
article(2),

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import { GraphQLSchema } from '../../type/schema';
99
import { GraphQLString, GraphQLBoolean } from '../../type/scalars';
1010
import {
1111
GraphQLList,
12+
GraphQLUnionType,
1213
GraphQLObjectType,
1314
GraphQLInterfaceType,
14-
GraphQLUnionType,
1515
} from '../../type/definition';
1616

1717
import { executeSync } from '../execute';
@@ -70,15 +70,15 @@ const NamedType = new GraphQLInterfaceType({
7070
const LifeType = new GraphQLInterfaceType({
7171
name: 'Life',
7272
fields: () => ({
73-
progeny: { type: GraphQLList(LifeType) },
73+
progeny: { type: new GraphQLList(LifeType) },
7474
}),
7575
});
7676

7777
const MammalType = new GraphQLInterfaceType({
7878
name: 'Mammal',
7979
interfaces: [LifeType],
8080
fields: () => ({
81-
progeny: { type: GraphQLList(MammalType) },
81+
progeny: { type: new GraphQLList(MammalType) },
8282
mother: { type: MammalType },
8383
father: { type: MammalType },
8484
}),
@@ -90,7 +90,7 @@ const DogType = new GraphQLObjectType({
9090
fields: () => ({
9191
name: { type: GraphQLString },
9292
barks: { type: GraphQLBoolean },
93-
progeny: { type: GraphQLList(DogType) },
93+
progeny: { type: new GraphQLList(DogType) },
9494
mother: { type: DogType },
9595
father: { type: DogType },
9696
}),
@@ -103,7 +103,7 @@ const CatType = new GraphQLObjectType({
103103
fields: () => ({
104104
name: { type: GraphQLString },
105105
meows: { type: GraphQLBoolean },
106-
progeny: { type: GraphQLList(CatType) },
106+
progeny: { type: new GraphQLList(CatType) },
107107
mother: { type: CatType },
108108
father: { type: CatType },
109109
}),
@@ -132,9 +132,9 @@ const PersonType = new GraphQLObjectType({
132132
interfaces: [NamedType, MammalType, LifeType],
133133
fields: () => ({
134134
name: { type: GraphQLString },
135-
pets: { type: GraphQLList(PetType) },
136-
friends: { type: GraphQLList(NamedType) },
137-
progeny: { type: GraphQLList(PersonType) },
135+
pets: { type: new GraphQLList(PetType) },
136+
friends: { type: new GraphQLList(NamedType) },
137+
progeny: { type: new GraphQLList(PersonType) },
138138
mother: { type: PersonType },
139139
father: { type: PersonType },
140140
}),
@@ -523,7 +523,7 @@ describe('Execute: Union and intersection types', () => {
523523
interfaces: [NamedType2],
524524
fields: {
525525
name: { type: GraphQLString },
526-
friends: { type: GraphQLList(NamedType2) },
526+
friends: { type: new GraphQLList(NamedType2) },
527527
},
528528
});
529529
const schema2 = new GraphQLSchema({ query: PersonType2 });

0 commit comments

Comments
 (0)