Given this GraphQL enum definition and query, what is the output?
enum Status {
ACTIVE
INACTIVE
PENDING
}
type User {
id: ID!
name: String!
status: Status!
}
query {
user(id: "1") {
name
status
}
}Assume the user with id "1" has status ACTIVE.
Enum values in GraphQL are case sensitive and returned as defined.
The enum value is returned exactly as defined in the schema, in uppercase. So the status is "ACTIVE".
Choose the correct statement about enums in GraphQL.
Think about how enums are defined and used in GraphQL schemas.
GraphQL enums must have unique names, are case sensitive, and typically use uppercase letters without spaces.
Which option correctly fixes the syntax error in this GraphQL enum?
enum Color {
RED
GREEN
BLUE
LIGHT BLUE
}Enum values cannot contain spaces.
Enum values must be valid names without spaces. Using underscore is the correct fix.
Given this schema snippet:
enum Role {
ADMIN
USER
GUEST
}
type Query {
usersByRole(role: Role!): [User!]!
}And this query:
query {
usersByRole(role: "ADMIN") {
id
name
}
}Why does the query fail?
Think about how enum values are passed as arguments in GraphQL queries.
Enum values are passed without quotes in GraphQL queries. Passing "ADMIN" as a string causes an error.
You have a schema with a 'status' field as a string with possible values 'active', 'inactive', 'pending'. Which change optimizes the schema for better validation and clarity?
Enums help restrict values and improve schema clarity.
Using an enum for 'status' restricts allowed values and makes the schema clearer and safer.