Skip to content

Warning when use GraphQLNonNull or GraphQLList #2338

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
amjedomar opened this issue Jan 6, 2020 · 1 comment
Closed

Warning when use GraphQLNonNull or GraphQLList #2338

amjedomar opened this issue Jan 6, 2020 · 1 comment

Comments

@amjedomar
Copy link

amjedomar commented Jan 6, 2020

The official graphql-js document refers that GraphQLNonNull is a class so if I want to use it I have to instantiate it and then pass a valid graphql type to it

But when I do that the IDE that I use (WebStorm) show me a warning about that:

Interface can not be instantiated

GraphQLNonNull

However, the warning disappears when I use it without instantiating it (without writing new keyword before it)

GraphQLNonNull2

This problem is also happening with GraphQLList

@amjedomar amjedomar changed the title GraphQLNonNull Warning Warning when use GraphQLNonNull or GraphQLList Jan 6, 2020
@mjmahone
Copy link
Contributor

This is intentional: the types are interfaces, and GraphQLNonNull(ofType) is a method to get you a concrete instance of the GraphQLNonNull. This for instance helps prevent usages of instanceof that have caused issues in the past.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants