I have a GraphQL query string as
query = """
{
scripts(developers: "1") {
...
...
}
}
"""
Q. How can I change the value of developers by using Python string formatting technique?
What I have tried so far,
1.using f-string
In [1]: query = f"""
...: {
...: scripts(developers: "1") {
...:
...: ...
...: ...
...: }
...: }
...: """
File "<fstring>", line 2
scripts(developers: "1") {
^
SyntaxError: invalid syntax
2.using .format() method
In [2]: query = """
...: {
...: scripts(developers: "{dev_id}") {
...:
...: ...
...: ...
...: }
...: }
...: """
...:
...: query.format(dev_id=123)
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-2-058a3791fe41> in <module>
9 """
10
---> 11 query.format(dev_id=123)
KeyError: '\n scripts(developers'