This is documentation for v11, which is no longer actively maintained.
For up-to-date documentation, see the latest version.

Enums

An Enum is a special kind of scalar that is restricted to a particular set of allowed values.

SDL
enum UserRole {
GUEST,
DEFAULT,
ADMINISTRATOR
}

Learn more about enums here.

Usage

We can define enums like the following.

C#
public enum UserRole
{
Guest,
Standard,
Administrator
}
public class Query
{
public User[] GetUsers(UserRole role)
{
// Omitted code for brevity
}
}

We can also specify different names for the type and values to be used in the schema.

C#
[GraphQLName("NewUserRole")]
public enum UserRole
{
Guest,
[GraphQLName("Default")]
Standard,
Administrator
}