mirror of
https://github.com/atulmy/gql-query-builder.git
synced 2026-04-25 23:55:55 +03:00
[GH-ISSUE #15] Can't pass in variables. #9
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/gql-query-builder#9
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @dChunikhin on GitHub (Jul 2, 2019).
Original GitHub issue: https://github.com/atulmy/gql-query-builder/issues/15
Hello. Help me, please.
returns
query ($id: Int) { user (id: $id) { name, balance } }instead of
query ($id: Int) { user (id: 333) { name, balance } }Shortly, your feature doesn't inject variables values into resulting query string.
@dChunikhin commented on GitHub (Jul 2, 2019):
Or, if it is predicted behavior, why you did it? It's expected that we will interpolate variables into query string, aren't we?
@atulmy commented on GitHub (Jul 2, 2019):
Since the query is a string, we could run into malformed query string and will have to escape the data passed, in your case
idto be escaped for any special characters colliding with GQL syntax. Hence we pass the variables as JSON in payload.You can learn more here: https://graphql.org/learn/queries/#variables
@dChunikhin commented on GitHub (Jul 2, 2019):
So, then i should interpolate vars from object variables into query string manually, before making request?
@atulmy commented on GitHub (Jul 2, 2019):
Did not understand your question there. You have to just pass your data (variable) to the query/mutation function and it'll automatically form the JSON payload containing the actual GraphQL query string and variables.
For example:
Feel free to let me know if you still have any doubts or questions.
@dChunikhin commented on GitHub (Jul 2, 2019):
My question was about data in a body of request. But, i have figured out alredy, so thx you for operative help!