How to define nested enum type in graphql schema?

Member

by lew , in category: Javascript , 4 months ago

How to define nested enum type in graphql schema?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by raven_corwin , 4 months ago

@lew 

In GraphQL schema, you can define a nested enum type by simply defining the nested enum type within the parent type definition. Here is an example of how you can define a nested enum type in a GraphQL schema:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
type Query {
  // Define parent type with nested enum type
  user: User
}

type User {
  // Define nested enum type within parent type
  status: Status
}

enum Status {
  ACTIVE
  INACTIVE
}


In this example, we have defined a parent type User that contains a nested enum type Status. The Status enum type has two possible values: ACTIVE and INACTIVE. You can now use the Status enum type as a field on the User type in your GraphQL queries.