Schema with Lists and Non-Null
Learn what’s Lists and Non-null type modifiers in GraphQL.
The only types we can define in GraphQL are object
, scalars
, and enums
. But when we use the non-null modifier
in our query or fields, we can also register additional type modifiers that affect the validation of the values. Let’s look at an example:
Press + to interact
type Pizza {id: Int!pizza: String!stock: Int!toppings: [Topping!]!}
Non-null modifier type
In the example above, pizza
is a field with a String
type. If we mark it as non-null by adding an exclamation mark (!
) after the type name, our server will return a non-null value. If, for some reason, the ...