GraphQL Tutorial - Network error: Unexpected end of JSON input

Highlighted
New Member
2 0 2

Hi

Im working thru the GraphQL tutorial and am getting a "Unexpected end" error 

Ive tried taking the Master from https://github.com/Shopify/shopify-demo-app-node-react/tree/master and same error

 

Behind the scenes its a 406 error on the graphql POST -

  1. {operationName: "getProducts", variables: {ids: ["gid://shopify/Product/5412690559143"]},…}
    1. operationName: "getProducts"
    2. query: "query getProducts($ids: [ID!]!) {↵ nodes(ids: $ids) {↵ ... on Product {↵ title↵ handle↵ descriptionHtml↵ id↵ images(first: 1) {↵ edges {↵ node {↵ originalSrc↵ altText↵ __typename↵ }↵ __typename↵ }↵ __typename↵ }↵ variants(first: 1) {↵ edges {↵ node {↵ price↵ id↵ __typename↵ }↵ __typename↵ }↵ __typename↵ }↵ __typename↵ }↵ __typename↵ }↵}↵"
    3. variables: {ids: ["gid://shopify/Product/5412690559143"]}

 

I can run the same request from the Graphiql app and it is successful - now the main difference looks like CORS

 

Any ideas on this issue?

 

Thanks

 

1 Like
Highlighted
New Member
2 0 2

Hi

The issue was that the tutorial is using a mix of ApiVersions -

https://github.com/Shopify/shopify-demo-app-node-react/blob/master/server.js

Hook - 

apiVersion: ApiVersion.October19

Server - 

server.use(graphQLProxy({ version: ApiVersion.April19 }));

I upgraded to -

ApiVersion.July20

And its working - might be worth updating the tutorial with a suggestion to update the graphql version if the master project in github stops working

 

1 Like
Highlighted
Shopify Staff
Shopify Staff
38 4 4

Thanks for identifying that @martinglen,

Although the tutorial does already suggest that "In most cases, you'll always want to use the most recent version of the API." in step 5 of https://shopify.dev/tutorials/build-a-shopify-app-with-node-and-react/fetch-data-with-apollo, I can see how that might be confusing when specified differently on those two lines in the source.

The server.js file in github has been updated to reflect the most recent July20 version.

Callum | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes