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
Solved! Go to the solution
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.
Thank you @davetron5000 . Reverting to 2.1.5 allows me to continue and get past the error. Thanks a lot :+1:
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.
Hi there, chipmunkgeek is right! The koa-shopify-graphql-proxy has been updated to accept a version parameter.
The guide now reflects this change:
Sorry for confusion. Thanks for bringing it to our attention!
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?
User | Count |
---|---|
16 | |
12 | |
7 | |
5 | |
5 |