I am preparing a GraphQL query string in Python, I need to interpolate three variables in the string, there is just one problem. GraphQL contains a lot of curly brackets and it interferes with the way Python f strings work.
number = 10
owner = "me"
name = "my_repo"
query = f"""
query {
repository(owner:"{owner}", name:"{repo}") {
pullRequests(first: {number}) {
edges {
node {
state
merged
createdAt
}
}
}
}
}
"""
Code above raises SyntaxError. So I assume I need to drop using f strings altogether? Is there a way to still use f string in Python when it contains curly brackets unrelated to the interpolation?