I am unsure how yours variables are being substituted into your query. There are no GraphQL variables defined in it, nor are you providing the variables in your payload.
f strings are your enemy not your friend for this task, even though you’ve probably seen them all over for GraphQL examples. Trying to ensure quotes are escaped correctly, etc. is a nightmare you don’t have to endure.
GraphQL queries are strings, you can define variables in them (not to be substituted as part of an f-string, but by the API server itself!), then pass variables as a separate object in your request.
GraphQL requests are JSON of objects that have two keys, query
and variables
. query
is your query string (the mutation in this case, with the word mutation at the start, basically just copied right out of the playground as a string)
variables
is an object with a key for each variable name used in the query string, and the value is the value for the variable - it needs to be the correct type. The documentation lists the types of arguments. JSON type means its an object that has been serialized to a JSON string using json.dumps.
You then serialize the request object to json and send it.
Here is a longer thread that may also provide some light.
Below is a link directly to the variables section.