I would like to modify this string:
query = """
mutation {
productUpdate(input: {id: "gid://shopify/Product/463...03", title: "test", descriptionHtml: "Amazing product"}) {
product {
id
}
userErrors {
field
message
}
}
}
"""
I’m trying to put a variable in the place of “test” and “Amazing product”. Normally i would do this with f-strings, but because of the GraphQL brackets i cannot do this.
Does anyone have an idea on how to solve this problem?
Many thanks!
3
Answers
While fstrings are great, in case of graphql queries you can just use below format.
you can double up the curly braces to escape them:
https://docs.python.org/3/reference/lexical_analysis.html#formatted-string-literals
You can use the graphql-python/gql package. It supports variables.