[Bug]: GraphQL mutation does not properly handle variables
See original GitHub issueWhat happened?
Description:
I’ve been using the DataApiBuilder with a StaticWebApp in production, and I’ve encountered an issue where the GraphQL mutation does not correctly handle variables when sent in a request. Instead of using the provided variable values, the mutation uses the variable names themselves as the field values.
To reproduce the issue, I used the following GraphQL mutation as an example:
mutation CreateExample($id: ID!, $name: String!) {
createExample(
item: {
id: $id,
name: $name
}
) {
id
name
}
}
And the variables:
{
"id": "1234",
"name": "Test Example"
}
When I send this mutation using a JSON payload in a POST request to the DataApiBuilder, the server incorrectly stores the values as “id” and “name” instead of the provided values “1234” and “Test Example”.
I was able to reproduce this issue using Postman, and it seems to be a bug in the DataApiBuilder code. Could you please investigate this issue and provide guidance on how to resolve it?
Steps to reproduce:
- Set up a StaticWebApp with DataApiBuilder as the backend.
- Define the schema for the GraphQL mutation as shown above.
- Send a POST request with the JSON payload containing the mutation and variables.
- Observe the incorrect handling of variables in the server response and stored data.
Expected behavior:
The GraphQL mutation should properly handle variables and store the provided values in the corresponding fields.
Actual behavior:
The GraphQL mutation uses the variable names as the field values, not the actual variable values provided.
Thank you for looking into this issue.
Version
0.6.14+b21a924c4a9220e9cdef36032786b531c6394251
What database are you using?
CosmosDB NoSQL
What hosting model are you using?
Local (including CLI), Static Web Apps (SWA)
Which API approach are you accessing DAB through?
GraphQL
Relevant log output
No response
Code of Conduct
- I agree to follow this project’s Code of Conduct
Issue Analytics
- State:
- Created 4 months ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Thanks @tarazou9, but everything fine. Hope you find the bug 😃
Anything new?