Skip to content

Covariant Wrapping Types #1136

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

Merged
merged 1 commit into from
Dec 12, 2017
Merged
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
22 changes: 11 additions & 11 deletions src/__tests__/starWarsSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,21 @@ const characterInterface = new GraphQLInterfaceType({
description: 'A character in the Star Wars Trilogy',
fields: () => ({
id: {
type: new GraphQLNonNull(GraphQLString),
type: GraphQLNonNull(GraphQLString),
description: 'The id of the character.',
},
name: {
type: GraphQLString,
description: 'The name of the character.',
},
friends: {
type: new GraphQLList(characterInterface),
type: GraphQLList(characterInterface),
description:
'The friends of the character, or an empty list if they ' +
'have none.',
},
appearsIn: {
type: new GraphQLList(episodeEnum),
type: GraphQLList(episodeEnum),
description: 'Which movies they appear in.',
},
secretBackstory: {
Expand Down Expand Up @@ -159,21 +159,21 @@ const humanType = new GraphQLObjectType({
description: 'A humanoid creature in the Star Wars universe.',
fields: () => ({
id: {
type: new GraphQLNonNull(GraphQLString),
type: GraphQLNonNull(GraphQLString),
description: 'The id of the human.',
},
name: {
type: GraphQLString,
description: 'The name of the human.',
},
friends: {
type: new GraphQLList(characterInterface),
type: GraphQLList(characterInterface),
description:
'The friends of the human, or an empty list if they have none.',
resolve: human => getFriends(human),
},
appearsIn: {
type: new GraphQLList(episodeEnum),
type: GraphQLList(episodeEnum),
description: 'Which movies they appear in.',
},
homePlanet: {
Expand Down Expand Up @@ -209,21 +209,21 @@ const droidType = new GraphQLObjectType({
description: 'A mechanical creature in the Star Wars universe.',
fields: () => ({
id: {
type: new GraphQLNonNull(GraphQLString),
type: GraphQLNonNull(GraphQLString),
description: 'The id of the droid.',
},
name: {
type: GraphQLString,
description: 'The name of the droid.',
},
friends: {
type: new GraphQLList(characterInterface),
type: GraphQLList(characterInterface),
description:
'The friends of the droid, or an empty list if they have none.',
resolve: droid => getFriends(droid),
},
appearsIn: {
type: new GraphQLList(episodeEnum),
type: GraphQLList(episodeEnum),
description: 'Which movies they appear in.',
},
secretBackstory: {
Expand Down Expand Up @@ -275,7 +275,7 @@ const queryType = new GraphQLObjectType({
args: {
id: {
description: 'id of the human',
type: new GraphQLNonNull(GraphQLString),
type: GraphQLNonNull(GraphQLString),
},
},
resolve: (root, { id }) => getHuman(id),
Expand All @@ -285,7 +285,7 @@ const queryType = new GraphQLObjectType({
args: {
id: {
description: 'id of the droid',
type: new GraphQLNonNull(GraphQLString),
type: GraphQLNonNull(GraphQLString),
},
},
resolve: (root, { id }) => getDroid(id),
Expand Down
14 changes: 7 additions & 7 deletions src/execution/__tests__/abstract-promise-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: GraphQLList(PetType),
resolve() {
return [new Dog('Odie', true), new Cat('Garfield', false)];
},
Expand Down Expand Up @@ -145,7 +145,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: GraphQLList(PetType),
resolve() {
return [new Dog('Odie', true), new Cat('Garfield', false)];
},
Expand Down Expand Up @@ -217,7 +217,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: GraphQLList(PetType),
resolve() {
return [new Dog('Odie', true), new Cat('Garfield', false)];
},
Expand Down Expand Up @@ -304,7 +304,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: GraphQLList(PetType),
resolve() {
return Promise.resolve([
new Dog('Odie', true),
Expand Down Expand Up @@ -400,7 +400,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: GraphQLList(PetType),
resolve() {
return [
new Dog('Odie', true),
Expand Down Expand Up @@ -489,7 +489,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: GraphQLList(PetType),
resolve() {
return [new Dog('Odie', true), new Cat('Garfield', false)];
},
Expand Down Expand Up @@ -561,7 +561,7 @@ describe('Execute: Handles execution of abstract types with promises', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: GraphQLList(PetType),
resolve() {
return [new Dog('Odie', true), new Cat('Garfield', false)];
},
Expand Down
10 changes: 5 additions & 5 deletions src/execution/__tests__/abstract-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('Execute: Handles execution of abstract types', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: GraphQLList(PetType),
resolve() {
return [new Dog('Odie', true), new Cat('Garfield', false)];
},
Expand Down Expand Up @@ -141,7 +141,7 @@ describe('Execute: Handles execution of abstract types', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: GraphQLList(PetType),
resolve() {
return [new Dog('Odie', true), new Cat('Garfield', false)];
},
Expand Down Expand Up @@ -226,7 +226,7 @@ describe('Execute: Handles execution of abstract types', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: GraphQLList(PetType),
resolve() {
return [
new Dog('Odie', true),
Expand Down Expand Up @@ -320,7 +320,7 @@ describe('Execute: Handles execution of abstract types', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: GraphQLList(PetType),
resolve() {
return [
new Dog('Odie', true),
Expand Down Expand Up @@ -407,7 +407,7 @@ describe('Execute: Handles execution of abstract types', () => {
name: 'Query',
fields: {
pets: {
type: new GraphQLList(PetType),
type: GraphQLList(PetType),
resolve() {
return [new Dog('Odie', true), new Cat('Garfield', false)];
},
Expand Down
14 changes: 7 additions & 7 deletions src/execution/__tests__/executor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,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: GraphQLList(GraphQLString) },
deeper: { type: GraphQLList(DataType) },
},
});

Expand Down Expand Up @@ -448,7 +448,7 @@ describe('Execute: Handles basic execution tasks', () => {
syncError: { type: GraphQLString },
syncRawError: { type: GraphQLString },
syncReturnError: { type: GraphQLString },
syncReturnErrorList: { type: new GraphQLList(GraphQLString) },
syncReturnErrorList: { type: GraphQLList(GraphQLString) },
async: { type: GraphQLString },
asyncReject: { type: GraphQLString },
asyncRawReject: { type: GraphQLString },
Expand Down Expand Up @@ -550,7 +550,7 @@ describe('Execute: Handles basic execution tasks', () => {
name: 'Query',
fields: {
foods: {
type: new GraphQLList(
type: GraphQLList(
new GraphQLObjectType({
name: 'Food',
fields: {
Expand Down Expand Up @@ -597,11 +597,11 @@ describe('Execute: Handles basic execution tasks', () => {
resolve: () => ({}),
},
nonNullA: {
type: new GraphQLNonNull(A),
type: GraphQLNonNull(A),
resolve: () => ({}),
},
throws: {
type: new GraphQLNonNull(GraphQLString),
type: GraphQLNonNull(GraphQLString),
resolve: () => {
throw new Error('Catch me if you can');
},
Expand Down Expand Up @@ -1034,7 +1034,7 @@ describe('Execute: Handles basic execution tasks', () => {
name: 'Query',
fields: {
specials: {
type: new GraphQLList(SpecialType),
type: GraphQLList(SpecialType),
resolve: rootValue => rootValue.specials,
},
},
Expand Down
18 changes: 8 additions & 10 deletions src/execution/__tests__/lists-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('Execute: Accepts any iterable as list value', () => {
it(
'Accepts a Set as a List value',
check(
new GraphQLList(GraphQLString),
GraphQLList(GraphQLString),
new Set(['apple', 'banana', 'apple', 'coconut']),
{ data: { nest: { test: ['apple', 'banana', 'coconut'] } } },
),
Expand All @@ -84,7 +84,7 @@ describe('Execute: Accepts any iterable as list value', () => {

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

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

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

describe('Execute: Handles list nullability', () => {
describe('[T]', () => {
const type = new GraphQLList(GraphQLInt);
const type = GraphQLList(GraphQLInt);

describe('Array<T>', () => {
it(
Expand Down Expand Up @@ -203,7 +203,7 @@ describe('Execute: Handles list nullability', () => {
});

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

describe('Array<T>', () => {
it(
Expand Down Expand Up @@ -311,7 +311,7 @@ describe('Execute: Handles list nullability', () => {
});

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

describe('Array<T>', () => {
it(
Expand Down Expand Up @@ -422,9 +422,7 @@ describe('Execute: Handles list nullability', () => {
});

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

describe('Array<T>', () => {
it(
Expand Down
8 changes: 4 additions & 4 deletions src/execution/__tests__/nonnull-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ const dataType = new GraphQLObjectType({
name: 'DataType',
fields: () => ({
sync: { type: GraphQLString },
nonNullSync: { type: new GraphQLNonNull(GraphQLString) },
nonNullSync: { type: GraphQLNonNull(GraphQLString) },
promise: { type: GraphQLString },
nonNullPromise: { type: new GraphQLNonNull(GraphQLString) },
nonNullPromise: { type: GraphQLNonNull(GraphQLString) },
nest: { type: dataType },
nonNullNest: { type: new GraphQLNonNull(dataType) },
nonNullNest: { type: GraphQLNonNull(dataType) },
promiseNest: { type: dataType },
nonNullPromiseNest: { type: new GraphQLNonNull(dataType) },
nonNullPromiseNest: { type: GraphQLNonNull(dataType) },
}),
});
const schema = new GraphQLSchema({
Expand Down
6 changes: 3 additions & 3 deletions src/execution/__tests__/schema-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ describe('Execute: Handles execution with a complex schema', () => {
const BlogArticle = new GraphQLObjectType({
name: 'Article',
fields: {
id: { type: new GraphQLNonNull(GraphQLString) },
id: { type: GraphQLNonNull(GraphQLString) },
isPublished: { type: GraphQLBoolean },
author: { type: BlogAuthor },
title: { type: GraphQLString },
body: { type: GraphQLString },
keywords: { type: new GraphQLList(GraphQLString) },
keywords: { type: GraphQLList(GraphQLString) },
},
});

Expand All @@ -67,7 +67,7 @@ describe('Execute: Handles execution with a complex schema', () => {
resolve: (_, { id }) => article(id),
},
feed: {
type: new GraphQLList(BlogArticle),
type: GraphQLList(BlogArticle),
resolve: () => [
article(1),
article(2),
Expand Down
6 changes: 3 additions & 3 deletions src/execution/__tests__/union-interface-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,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: GraphQLList(PetType) },
friends: { type: GraphQLList(NamedType) },
},
isTypeOf: value => value instanceof Person,
});
Expand Down Expand Up @@ -341,7 +341,7 @@ describe('Execute: Union and intersection types', () => {
interfaces: [NamedType2],
fields: {
name: { type: GraphQLString },
friends: { type: new GraphQLList(NamedType2) },
friends: { type: GraphQLList(NamedType2) },
},
});

Expand Down
Loading