-2

What is the purpose of appending ! after String param in graphql methods.

query method($param: String!)

Rajan Rajan M
  • 65
  • 1
  • 3
  • 3
    Does this answer your question? [What is an exclamation point in GraphQL?](https://stackoverflow.com/questions/50684231/what-is-an-exclamation-point-in-graphql) – Malte Köhrer Oct 23 '20 at 12:18

1 Answers1

0

This modifier means that the type cannot be null.

String! means that the field is non-nullable, meaning that the GraphQL service promises to always give you a value when you query this field. In the type language, we'll represent those with an exclamation mark

The Non-Null type modifier can also be used when defining arguments for a field, which will cause the GraphQL server to return a validation error if a null value is passed as that argument, whether in the GraphQL string or in the variables.

https://graphql.org/learn/schema/#type-system

What is an exclamation point in GraphQL?

David
  • 306
  • 4
  • 13