TypeError: Cannot use 'in' operator to search for 'shop' in undefined / koa-shopify-graphql-proxy

Solved
Ray_Ban_xyz
Shopify Partner
3 0 2

I ran into some errors while following your tutorial on creating a Shopify app with React and GraphQl

 

TypeError: Cannot use 'in' operator to search for 'shop' in undefined at /Users/.../nodemodules/@shopify/koa-shopify-graphql-proxy/dist/shopify-graphql-proxy.js:21:39 at step (/Users/.../nodemodules/tslib/tslib.js:133:27) at Object.next (/Users/.../nodemodules/tslib/tslib.js:114:57) at/Users/.../nodemodules/tslib/tslib.js:107:75 at new Promise (<anonymous>) at Object._awaiter (/Users/.../nodemodules/tslib/tslib.js:103:16) at shopifyGraphQLProxyMiddleware (/Users/.../node_modules/@shopify/koa-shopify-graphql-proxy/dist/shopify-graphql-proxy.js:15:24

nscmnto
Shopify Partner
1 0 1

Same error here, still trying to figure it out.

Ray_Ban_xyz
Shopify Partner
3 0 2
Hello. If you found any solution. Please, post it here. Thank you :)
0 Likes
floppynub
New Member
3 0 0

It's impossible for anybody to help you unless you also post the code that is throwing the error.  My initial impressions from the error is that you have invalid Liquid code somewhere in your project.

0 Likes
davetron5000
Tourist
3 1 4

This is an accepted solution.

This happens when you get to  the "Set up GraphQL" of the tutorial at https://help.shopify.com/en/api/tutorials/build-a-shopify-app-with-node-and-react/fetch-data-with-ap...

 

Specifically, when adding 

 

server.use(graphQLProxy());

The stack trace does not contain any of my code.

 

I'm using this version of the node module:

 

    "@shopify/koa-shopify-graphql-proxy": {
      "resolved": "https://registry.npmjs.org/@shopify/koa-shopify-graphql-proxy/-/koa-shopify-graphql-proxy-3.0.1.tgz",

3.0.0 also causes this problem. Reverting to 2.1.5 seems to get past it.

 

That said, my server outputs this:

 

  Error: write EPIPE
      at WriteWrap.afterWrite [as oncomplete] (net.js:835:14)

Since there's no stack, no idea where it's coming from.

 

It did work more or less.  It's hard to figure out since there is no explanation of what anything is supposed to accomplish—I'm just pasting code where it says so no idea when things go wrong.

 

Ray_Ban_xyz
Shopify Partner
3 0 2

Thank you @davetron5000 . Reverting to 2.1.5 allows me to continue and get past the error. Thanks a lot :+1:

chipmunkgeek
New Member
1 0 3

It looks like there was a change in a recent commit for koa-shopify-graphql-proxy. I'm not sure if it was an intentional decision to do this, but the function for declaring an instance of the proxy - in the Shopfiy tutorial's instructions, that's the call to graphQlProxy() - used to work fine if no argument is provided. With the recent change (for example, if version 3.0.0), the function looks like it expects an object to be passed as a parameter. That's unfortunate.

 

Yes, downgrading to 2.1.5 works. Or, you can just call graphQLProxy() with an empty object as the parameter, like so:

server.use(graphQLProxy({}))

This got me passed the error too.

 

Here's where the change in the code happened: Github

 

Specifically, it is line 19 in the older version, compared with line 31 in the newer version.

katiedavis
Shopify Staff (Retired)
Shopify Staff (Retired)
39 7 10

Hi there, chipmunkgeek is right! The koa-shopify-graphql-proxy has been updated to accept a version parameter.

The guide now reflects this change:

https://developers.shopify.com/tutorials/build-a-shopify-app-with-node-and-react/fetch-data-with-apo...


Sorry for confusion. Thanks for bringing it to our attention! 

0 Likes
Mladen_J
Tourist
4 0 1

I am following the tutorial at the moment and I am still having this issue

0 Likes
abdillahalsree
New Member
4 0 0

I followed the tutorial closely but ran into errors when I included the server.use(graphQLProxy({version: ApiVersion.October19})). I had changed it to (graphQLProxy({version: ApiVersion.July20})) and (graphQLProxy({version: '2020-07'})) to reflect the latest stable API release but to no avail. 

This is the error I got:

event - compiled successfully
(node:14364) UnhandledPromiseRejectionWarning: TypeError: graphQLProxy is not a function
at C:\Users\Test\Documents\ShopifyNode1\server.js:49:16
(node:14364) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:14364) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Any ideas on how to solve it?

0 Likes