Update 6 JUL 2017 – Eventually the person got what he needed. Here are the links that helped.
Apollo Client https://www.npmjs.com/package/apollo-client
Apollo Tools and graphql-tools http://dev.apollodata.com/tools/graphql-tools/generate-schema.html
Shopify API reference https://help.shopify.com/api/storefront-api/reference/queryroot
Mocking a schema using introspection http://dev.apollodata.com/tools/graphql-tools/mocking.html#Mocking-a-schema-using-introspection
When I saw the following coding question in a forum I am subscribed to, I decided to see if I could help even though I have little experience with Node.js and none with GraphQL. GraphQL is a query language.
Been stuck the last couple days unable to marshall a schema for the Shopify GraphQL backend.
What I gather is that the person has the schema in JSON but needs it in GraphQL format. First thing I did was make sure that the person contacted Shopify support for guidance. Next thing was searched to see what was available and found json-to-graphql-schema. Then I downloaded Node.js (the latest version because that is what the person was using) . I am using Visual Studio Code and powershell on Windows 10. I copied the code under usage and ran that and got the following first error.
import generateSchema from ‘json-to-graphql’
SyntaxError: Unexpected token import
Found out that import is not supported in native environments although it is a part of ES6. Changed this to use require and continued. The next problem I encountered was that my json file saved with a .txt extension. Realised I needed to use ‘No extension’ as type in Save As. Then the code would not work with the json file the person linked to and gives the following error.
return word.toUpperCase() + word.slice(1);
TypeError: Cannot read property ‘toUpperCase’ of undefined
The code does work with api.js found under json-to-graphql-schema’s node_modules\json-to-graphql\__tests__ folder. Then it hit me that this is for json data to GraphQL schema and probaly in a specific format. Looked around and found this other package jsonschema-to-graphql.
At this point I realised it was getting somewhat involved and I needed to understand more of what needed to be done. Sharing here on my blog in case this is helpful to anyone and maybe if I dig further I will update this blog post. Additionally you will encounter the below error using the exact code under usage. Removed callback and then was left with a warning which I could live with for what I was doing.
ReferenceError: callback is not defined
What happens if there is an error.
(node:2632) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.