When you're passing arguments in code, it's generally better to avoid constructing the whole query/mutation string yourself. Instead, you can use $
syntax to define variables in your operation, and pass the variables as a separate map. See GraphQL variable documentation.
Note: Any query or mutation arguments of GraphQL type String
must be provided to the server as variables instead of inline. An $id
is of type ID
permitting it to be defined inline.
- Operation
-
query ($id: ID!) { business(id: $id) { name phone } }
- Operation Variables
-
{ "id": "QnVzaW5lc3M6MWRhMmExNzctNzg2OC00NmMxLTgzMzktM2M4NjdlZDJlZGQ5" }
- Response
-
{ "data": { "business": { "name": "Smith Consulting", "phone": null } } }