When I run this, I get an error saying ‘syntax error, unexpected invalid token (“"”) at [33, 2]’. Can someone explain what’s causing this and how to fix it? I’m new to GraphQL and could use some guidance. Thanks!
The issue likely stems from a mismatch between your GraphQL query structure and the data you’re passing. Shopify’s API expects a specific format for inventory updates. Try modifying your data structure as follows:
This aligns the data with the expected StockAdjustmentInput format. Additionally, ensure your sendGraphQLQuery function properly encodes the variables as JSON. If problems persist, consider using Shopify’s GraphQL explorer to validate your query structure before implementation.
I’ve run into similar issues with the Shopify GraphQL API before. The error you’re seeing is likely due to a mismatch between your query structure and the data you’re sending.
From what I can see, your query is expecting a list of StockAdjustmentInput objects, but your data structure doesn’t quite match that. Try restructuring your $data array like this:
This should align better with the expected input format. Also, double-check that your sendGraphQLQuery function is properly encoding the variables as JSON before sending the request.
If you’re still having trouble, I’d recommend using Shopify’s GraphQL explorer to test your queries first. It can help catch these kinds of structural errors before you implement them in your code.