The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Use GraphQLNonNull for Required Fields

Use GraphQLNonNull for Required Fields

2:05
While certain fields in a GraphQL Schema can be optional, there are some fields or arguments that are necessary in order to either fulfill a query, or to provide a guarantee to people using the Schema that some field exists. In this video, we'll take a look at turning an argument in a NonNull argument by applying the GraphQLNonNull type in order to guarantee that the given argument is supplied in the query.
Watch this lesson now
Avatar
egghead.io

While certain fields in a GraphQL Schema can be optional, there are some fields or arguments that are necessary in order to either fulfill a query, or to provide a guarantee to people using the Schema that some field exists. In this video, we'll take a look at turning an argument in a NonNull argument by applying the GraphQLNonNull type in order to guarantee that the given argument is supplied in the query.

Avatar
IT

i get error, GraphQLNonNUll is not a constructor. This video is wrong.

In reply to egghead.io
Avatar
Josh Black

Hi there! Sorry to hear about the issue you're experiencing.

Unless there's been a significant change recently, GraphQLNonNull should still be a type that's exported from the graphql module and can be used as a constructor.

For reference, you can visit the graphql site to verify the expected behavior here.

You can also check the graphql repo to verify that GraphQLNonNull is an export here.

Hope that helps!

In reply to IT
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?