How can I get the arguments and types of graphql mutations via introspection?
If you would like to get the arguments of a specific mutation, you can use an introspection query to get its InputObject type.
Say you have a create user mutation that looks something like this
mutation createUser($input: CreateUserInput!) {
create_user(input: $input) {
user {
id
name
}
}
}
You can then use an introspection query to get the CreateUserInput
query createUserInput {
__type(name: "CreateUserInput") {
name
inputFields {
name
description
defaultValue
}
}
}
and use the inputFields
from that query to see the mutations arguments. gql introspection docs
Read more here: Source link