I am trying to make a mutation to my Shopify store from python. I am new to graphQL, I have been able to make the mutation using graphiQL but I am not certain how to do it directly from my code.
This is my make query file, it has worked successfully for a simple query
`import requests
def make_query(self, query, url, headers):
"""
Return query response
"""
request = requests.post(url, json={'query': query}, headers=headers)
if request.status_code == 200:
return request.json()
else:
raise Exception("Query failed to run by returning code of {}. {}".format(request.status_code, query))`
Now an example of the mutation that worked in graphiQL is this:
"mutation {customerCreate(input: {email: '[email protected]', password: 'password'}) {userErrors { field message}customer{id}}}"
But when I pass it into my make_query function it gives this error
{'errors': [{'message': 'Parse error on "\'" (error) at [1, 41]', 'locations': [{'line': 1, 'column': 41}]}]}
How do I fix this? Also one of the mutations I am making uses variables, and I haven't been able to find an example of how to do this directly from my code