Closed arielvol closed 4 years ago
Hi @arielvol
You can check out the readme and perform the same logic using the query example, like this (taken from test_query):
def test_mutation_result(client):
query = gql(
"""
mutation CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) {
createReview(episode: $ep, review: $review) {
stars
commentary
}
}
"""
)
params = {
"ep": "JEDI",
"review": {"stars": 5, "commentary": "This is a great movie!"},
}
result = client.execute(query, variable_values=params)
Great!!! thank you @KingDarBoja.
Still can't understand it(. Episode
is it a type?, why do we need "ep": "JEDI",
?
An what if a mutation has no name, should it work like this: mutation ($ep: Episode!, $review: ReviewInput!)
Episode
is a enum type, that's why you need to specify the value between NEWHOPE
, EMPIRE
or JEDI
as you can seen at: https://github.com/graphql-python/gql/blob/master/tests/starwars/schema.py#L32
Can someone show me an example how to use execute method with the "gql" option and with a mutation example which also needs variables ?