Skip to content

Wrapper method on type classes #1054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/__tests__/starWarsSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
GraphQLEnumType,
GraphQLInterfaceType,
GraphQLObjectType,
GraphQLList,
GraphQLNonNull,
GraphQLSchema,
GraphQLString,
Expand Down Expand Up @@ -118,12 +117,12 @@ const characterInterface = new GraphQLInterfaceType({
description: 'The name of the character.',
},
friends: {
type: new GraphQLList(characterInterface),
type: characterInterface.wrapList(),
description: 'The friends of the character, or an empty list if they ' +
'have none.',
},
appearsIn: {
type: new GraphQLList(episodeEnum),
type: episodeEnum.wrapList(),
description: 'Which movies they appear in.',
},
secretBackstory: {
Expand Down Expand Up @@ -166,13 +165,13 @@ const humanType = new GraphQLObjectType({
description: 'The name of the human.',
},
friends: {
type: new GraphQLList(characterInterface),
type: characterInterface.wrapList(),
description:
'The friends of the human, or an empty list if they have none.',
resolve: human => getFriends(human),
},
appearsIn: {
type: new GraphQLList(episodeEnum),
type: episodeEnum.wrapList(),
description: 'Which movies they appear in.',
},
homePlanet: {
Expand Down Expand Up @@ -216,13 +215,13 @@ const droidType = new GraphQLObjectType({
description: 'The name of the droid.',
},
friends: {
type: new GraphQLList(characterInterface),
type: characterInterface.wrapList(),
description:
'The friends of the droid, or an empty list if they have none.',
resolve: droid => getFriends(droid),
},
appearsIn: {
type: new GraphQLList(episodeEnum),
type: episodeEnum.wrapList(),
description: 'Which movies they appear in.',
},
secretBackstory: {
Expand Down
15 changes: 7 additions & 8 deletions src/execution/__tests__/abstract-promise-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
GraphQLObjectType,
GraphQLInterfaceType,
GraphQLUnionType,
GraphQLList,
GraphQLString,
GraphQLBoolean,
} from '../../';
Expand Down Expand Up @@ -73,7 +72,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: PetType.wrapList(),
resolve() {
return [ new Dog('Odie', true), new Cat('Garfield', false) ];
}
Expand Down Expand Up @@ -140,7 +139,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: PetType.wrapList(),
resolve() {
return [ new Dog('Odie', true), new Cat('Garfield', false) ];
}
Expand Down Expand Up @@ -212,7 +211,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: PetType.wrapList(),
resolve() {
return [ new Dog('Odie', true), new Cat('Garfield', false) ];
}
Expand Down Expand Up @@ -290,7 +289,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: PetType.wrapList(),
resolve() {
return Promise.resolve([
new Dog('Odie', true),
Expand Down Expand Up @@ -380,7 +379,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: PetType.wrapList(),
resolve() {
return [
new Dog('Odie', true),
Expand Down Expand Up @@ -465,7 +464,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: PetType.wrapList(),
resolve() {
return [
new Dog('Odie', true),
Expand Down Expand Up @@ -536,7 +535,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: PetType.wrapList(),
resolve() {
return [
new Dog('Odie', true),
Expand Down
11 changes: 5 additions & 6 deletions src/execution/__tests__/abstract-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
GraphQLObjectType,
GraphQLInterfaceType,
GraphQLUnionType,
GraphQLList,
GraphQLString,
GraphQLBoolean,
} from '../../';
Expand Down Expand Up @@ -73,7 +72,7 @@ describe('Execute: Handles execution of abstract types', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: PetType.wrapList(),
resolve() {
return [ new Dog('Odie', true), new Cat('Garfield', false) ];
}
Expand Down Expand Up @@ -136,7 +135,7 @@ describe('Execute: Handles execution of abstract types', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: PetType.wrapList(),
resolve() {
return [ new Dog('Odie', true), new Cat('Garfield', false) ];
}
Expand Down Expand Up @@ -214,7 +213,7 @@ describe('Execute: Handles execution of abstract types', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: PetType.wrapList(),
resolve() {
return [
new Dog('Odie', true),
Expand Down Expand Up @@ -304,7 +303,7 @@ describe('Execute: Handles execution of abstract types', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: PetType.wrapList(),
resolve() {
return [
new Dog('Odie', true),
Expand Down Expand Up @@ -389,7 +388,7 @@ describe('Execute: Handles execution of abstract types', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: PetType.wrapList(),
resolve() {
return [
new Dog('Odie', true),
Expand Down
9 changes: 4 additions & 5 deletions src/execution/__tests__/executor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { parse } from '../../language';
import {
GraphQLSchema,
GraphQLObjectType,
GraphQLList,
GraphQLBoolean,
GraphQLInt,
GraphQLString,
Expand Down Expand Up @@ -180,8 +179,8 @@ describe('Execute: Handles basic execution tasks', () => {
fields: {
a: { type: GraphQLString },
b: { type: GraphQLString },
c: { type: new GraphQLList(GraphQLString) },
deeper: { type: new GraphQLList(DataType) },
c: { type: GraphQLString.wrapList() },
deeper: { type: DataType.wrapList() },
}
});

Expand Down Expand Up @@ -425,7 +424,7 @@ describe('Execute: Handles basic execution tasks', () => {
syncError: { type: GraphQLString },
syncRawError: { type: GraphQLString },
syncReturnError: { type: GraphQLString },
syncReturnErrorList: { type: new GraphQLList(GraphQLString) },
syncReturnErrorList: { type: GraphQLString.wrapList() },
async: { type: GraphQLString },
asyncReject: { type: GraphQLString },
asyncRawReject: { type: GraphQLString },
Expand Down Expand Up @@ -938,7 +937,7 @@ describe('Execute: Handles basic execution tasks', () => {
name: 'Query',
fields: {
specials: {
type: new GraphQLList(SpecialType),
type: SpecialType.wrapList(),
resolve: rootValue => rootValue.specials
}
}
Expand Down
17 changes: 8 additions & 9 deletions src/execution/__tests__/lists-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
GraphQLObjectType,
GraphQLString,
GraphQLInt,
GraphQLList,
GraphQLNonNull
} from '../../type';

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

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

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

it('Accepts function arguments as a List value', check(
new GraphQLList(GraphQLString),
GraphQLString.wrapList(),
getArgs('one', 'two'),
{ data: { nest: { test: [ 'one', 'two' ] } } }
));

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

describe('[T]', () => {
const type = new GraphQLList(GraphQLInt);
const type = GraphQLInt.wrapList();

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

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

describe('[T]!', () => {
const type = new GraphQLNonNull(new GraphQLList(GraphQLInt));
const type = new GraphQLNonNull(GraphQLInt.wrapList());

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

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

describe('[T!]', () => {
const type = new GraphQLList(new GraphQLNonNull(GraphQLInt));
const type = (new GraphQLNonNull(GraphQLInt)).wrapList();

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

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

describe('[T!]!', () => {
const type =
new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(GraphQLInt)));
new GraphQLNonNull((new GraphQLNonNull(GraphQLInt)).wrapList());

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

Expand Down
5 changes: 2 additions & 3 deletions src/execution/__tests__/schema-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { parse } from '../../language';
import {
GraphQLSchema,
GraphQLObjectType,
GraphQLList,
GraphQLNonNull,
GraphQLInt,
GraphQLString,
Expand Down Expand Up @@ -56,7 +55,7 @@ describe('Execute: Handles execution with a complex schema', () => {
author: { type: BlogAuthor },
title: { type: GraphQLString },
body: { type: GraphQLString },
keywords: { type: new GraphQLList(GraphQLString) }
keywords: { type: GraphQLString.wrapList() }
}
});

Expand All @@ -69,7 +68,7 @@ describe('Execute: Handles execution with a complex schema', () => {
resolve: (_, { id }) => article(id)
},
feed: {
type: new GraphQLList(BlogArticle),
type: BlogArticle.wrapList(),
resolve: () => [
article(1),
article(2),
Expand Down
7 changes: 3 additions & 4 deletions src/execution/__tests__/union-interface-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
GraphQLObjectType,
GraphQLInterfaceType,
GraphQLUnionType,
GraphQLList,
GraphQLString,
GraphQLBoolean
} from '../../type';
Expand Down Expand Up @@ -88,8 +87,8 @@ const PersonType = new GraphQLObjectType({
interfaces: [ NamedType ],
fields: {
name: { type: GraphQLString },
pets: { type: new GraphQLList(PetType) },
friends: { type: new GraphQLList(NamedType) },
pets: { type: PetType.wrapList() },
friends: { type: NamedType.wrapList() },
},
isTypeOf: value => value instanceof Person
});
Expand Down Expand Up @@ -369,7 +368,7 @@ describe('Execute: Union and intersection types', () => {
interfaces: [ NamedType2 ],
fields: {
name: { type: GraphQLString },
friends: { type: new GraphQLList(NamedType2) },
friends: { type: NamedType2.wrapList() },
},
});

Expand Down
11 changes: 5 additions & 6 deletions src/execution/__tests__/variables-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
GraphQLSchema,
GraphQLObjectType,
GraphQLInputObjectType,
GraphQLList,
GraphQLString,
GraphQLNonNull,
GraphQLScalarType
Expand Down Expand Up @@ -49,7 +48,7 @@ const TestInputObject = new GraphQLInputObjectType({
name: 'TestInputObject',
fields: {
a: { type: GraphQLString },
b: { type: new GraphQLList(GraphQLString) },
b: { type: GraphQLString.wrapList() },
c: { type: new GraphQLNonNull(GraphQLString) },
d: { type: TestComplexScalar },
}
Expand Down Expand Up @@ -97,23 +96,23 @@ const TestType = new GraphQLObjectType({
},
list: {
type: GraphQLString,
args: { input: { type: new GraphQLList(GraphQLString) } },
args: { input: { type: GraphQLString.wrapList() } },
resolve: (_, { input }) => input && JSON.stringify(input)
},
nnList: {
type: GraphQLString,
args: { input: { type: new GraphQLNonNull(new GraphQLList(GraphQLString)) } },
args: { input: { type: new GraphQLNonNull(GraphQLString.wrapList()) } },
resolve: (_, { input }) => input && JSON.stringify(input)
},
listNN: {
type: GraphQLString,
args: { input: { type: new GraphQLList(new GraphQLNonNull(GraphQLString)) } },
args: { input: { type: (new GraphQLNonNull(GraphQLString)).wrapList() } },
resolve: (_, { input }) => input && JSON.stringify(input)
},
nnListNN: {
type: GraphQLString,
args: { input: { type:
new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(GraphQLString)))
new GraphQLNonNull((new GraphQLNonNull(GraphQLString)).wrapList())
} },
resolve: (_, { input }) => input && JSON.stringify(input)
},
Expand Down
Loading