Skip to content

graphql new is not needed anymore for GraphQLNonNull #26988

@sibelius

Description

@sibelius

TypeScript Version: 3.0.3

Search Terms: graphql, GraphQLNonNull

Code

export const UserConnection = connectionDefinitions({
  name: 'User',
  nodeType: GraphQLNonNull(UserType),
});
// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.

image

src/modules/user/UserType.ts:39:13 - error TS2348: Value of type 'typeof GraphQLNonNull' is not callable. Did you mean to include 'new'?

39 nodeType: GraphQLNonNull(UserType),
~~~~~~~~~~~~~~~~~~~~~~~~

Expected behavior:

it should be able to use GraphQLNonNull without new keyword

Actual behavior:

it requires new keyword

Check this for more info of this change graphql/graphql-js#1136

How can I disable this error?

Playground Link:

http://www.typescriptlang.org/play/#src=import%20%7B%20GraphQLObjectType%2C%20GraphQLString%2C%20GraphQLBoolean%2C%20GraphQLNonNull%20%7D%20from%20'graphql'%3B%0D%0A%0D%0Aconst%20UserType%20%3D%0D%0A%20%20%20%20new%20GraphQLObjectType(%7B%0D%0A%20%20%20%20%20%20%20%20name%3A%20'User'%2C%0D%0A%20%20%20%20%20%20%20%20description%3A%20'User%20data'%2C%0D%0A%20%20%20%20%20%20%20%20fields%3A%20()%20%3D%3E%20(%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20_id%3A%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20type%3A%20GraphQLNonNull(GraphQLString)%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20resolve%3A%20user%20%3D%3E%20user._id%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20name%3A%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20type%3A%20GraphQLString%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20resolve%3A%20user%20%3D%3E%20user.name%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20email%3A%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20type%3A%20GraphQLString%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20resolve%3A%20user%20%3D%3E%20user.email%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20active%3A%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20type%3A%20GraphQLBoolean%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20resolve%3A%20user%20%3D%3E%20user.active%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%2C%0D%0A%20%20%20%20%20%20%20%20%7D)%2C%0D%0A%20%20%20%20%7D)%3B

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions