A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hi all,
Since yesterday (1st of august 2024), I get the following error when running Bulk Queries in GraphQl.
syntax error, unexpected invalid token (\"\\\"\") at [2, 32]
My query is as follows:
mutation MyMutation { bulkOperationRunQuery(query: "query Orders { orders(query: \"created_at:>'2024-07-26T09:21:56Z'\") { edges { node { id name totalDiscounts cartDiscountAmount createdAt billingAddress { address1 address2 city company country countryCode firstName id lastName name phone zip } shippingAddress { address1 address2 city company country countryCode firstName id lastName name phone zip } currentTotalPriceSet { shopMoney { amount currencyCode } } lineItems { edges { node { id name originalTotal originalUnitPrice quantity sku taxable title totalDiscount product { id } discountAllocations { discountApplication { allocationMethod index targetSelection targetType value { ... on MoneyV2 { amount currencyCode } ... on PricingPercentageValue { percentage } } } } } } } shippingLine { carrierIdentifier code custom deliveryCategory id phone price shippingRateHandle source title } fulfillmentOrders { edges { node { channelId createdAt fulfillAt fulfillBy id orderId orderName orderProcessedAt requestStatus status updatedAt } } } discountApplications { edges { node { allocationMethod index targetSelection targetType value { ... on MoneyV2 { amount currencyCode } ... on PricingPercentageValue { percentage } } } } } } } } }") { bulkOperation { id } } }
I solved this by removing all the new lines.
However I wonder if this is as intended. This makes the query much less readable.
Am I missing a setting or some documentation stating this change?
Kind regards,
Robert
Solved! Go to the solution
This is an accepted solution.
Hi again Robert - it's possible this was a temporary bug on our side and may have already been resolved.
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Same here, except for...
GraphqlQueryError: syntax error, unexpected invalid token ("\"") at [3, 31]
didn't find a workaround yet, it broke basically everything for us, can't update anything anymore.
Hi JoonasS,
I don't know which language you are using, but I fixed it by using a simple regex replace.
Regex.Replace(s, @"\t|\n|\r", " ");
Have you tried this? Or is it not possible in your solutions.
Thanks for the suggestion, but I'm updating metafields which have json values, so I need to add the \" for it to parse the values properly, I don't know what would work to go around this, and at the same time maintain the proper structure for the fields. I was "fixing" the prerequest, which was fine, the actual mutation was the one that needed fixing
For anyone else, here's an example how we fix the query so it passes
Thanks @RobertTres for the tip!
const bulkUpdate = {
data: `mutation {
bulkOperationRunMutation(
mutation: "mutation call($input: ProductVariantInput!) {
productVariantUpdate(input: $input) {
userErrors {
message
field
}
}
} ",
stagedUploadPath: "${stagedUploadPath}") {
bulkOperation {
id
url
status
}
userErrors {
message
field
}
}
}
`.replace(/\n/g, '').replace(/\t/g, '').replace(/\r/g, '')
Thanks, we also do something similar to fi xit. But it's really terrible something like is changed in a stable API. I hope Shopify will roll it back
Hi - is this still ongoing? Looking into this issue now.
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
I've done some more digging and can confirm it is indeed only bulkMutations that are affected, not bulk queries. As far as I see it's the same for all api versions
@Mickeydtails FYI...We have get this issue in the productCreate mutation. There is a new line in the product description that i have removed and all good now.
This fix worked for me, thank you.
My web app broke due to this unannounced change. I'm surprised Shopify allowed this to happen.
Yeah, they broke it.
I had to replace the escaped double quote (\") with an unescaped one (")
Before:
mutation { bulkOperationRunQuery(query: """query { products(query: \"updated_at:>'1999-12-31T23:00:00Z' AND published_status:published\") {
After:
mutation { bulkOperationRunQuery(query: """query { products(query: "updated_at:>'1999-12-31T23:00:00Z' AND published_status:published") {
Yes getting same error and it is fixed by removing all the new lines. You are right!
Same, luckily we have the ability to supply hotfix DLL drops for our software.
Has anyone from Shopify posted anything on why this has happened? A rollback plan? or something?
Hi Robert,
Are you still seeing this issue? Connecting with our team on this now.
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hi Liam,
I just checked and all the queries work again!
Did you already fix the problem?
This is an accepted solution.
Hi again Robert - it's possible this was a temporary bug on our side and may have already been resolved.
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hi Liam,
Thanks for looking into it!
I just re-tested our integration and still seeing the same issue
We do have a work around, removing newlines in the status query, however this has worked for a long time and just stopped working last week.
Update: The error we now get with the newlines is now: "Internal_Server_Error" instead of the unexpected invalid token (\"\\\"\") at [2, 32] type error