What types of graphql variable are allowed?

by cortez.connelly , in category: Javascript , 6 months ago

What types of graphql variable are allowed?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by ryan.murray , 6 months ago


In GraphQL, there are three types of variables that are allowed:

  1. Scalar Variables: These variables can hold any scalar value such as Int, Float, String, Boolean, or ID. These are the most commonly used variables in GraphQL.
  2. Enum Variables: Enum variables can hold one of a predefined set of values. Enum types are useful when you have a fixed set of options to choose from.
  3. Input Object Variables: Input object variables are used when you want to pass a complex object as an argument. These variables allow you to define a specific shape or structure for the input object.

It's worth noting that in addition to these basic variable types, GraphQL also allows you to use custom scalar types as variables. This provides flexibility in handling specific types of data.