I have object something like below:
type SomeEventInput {
event: Event
}
type Event {
type: EventType!
}
enum EventType {
MORNING
EVENING
AFTERNOON
MIDNIGHT
}
Mutation.SomeEvent(input: SomeEventInput!): Boolean!
What I am trying to test is something like:
mutation SomeEvent($input: SomeEventInput!) {
SomeEventInput(input: {Event: {type: MORNING}})
}
But it is showing the following error:
"message": "Variable \"$input\" is never used in operation \"SomeEvent\".",
You want to use an input type to define the parameters of a mutation rather than just a
type.Then like @loganfsmyth points out, you want to actually use the variable you define.
Server:
Client:
Then pass a variable into the mutation named
inputwith thenameandtypefields. GraphQL will error if type has a value that is not included in your enum.