Any one know of any decent tutorials or sample code to help me learn Shopify’s GraphQL Admin API? I am using Rails, and have checked out the Shopify API docs, but don’t seem to be getting anywhere.
I have the REST API working perfectly well, but can’t seem to get the GraphQL side working - I have heard that the GraphQL side is quicker than the REST API.
Thanks for your response. I have tried that, but I couldn’t get it to work. I am assuming that you need to set up the following first, then you can access the code you pasted?
yes, you would need to set the site and api version. Are you getting an error on running ShopifyAPI::GraphQL.client? If that’s the case you need to save the schema so it loads when created, the gem has a nice rake task, the below is for private apps.
Hmm, I’m running your exact code on my end and it’s working. The message that you are providing as well doesn’t give me anything to go off of. I’m not sure how you are running the code, if possible (and if your not already doing so), to run a rails c and run the code one line at a time to see where it may be failing?
I am just running it in my controller, I will try restart the app and see if that makes any difference. Just gotta wait for my workers to finishing processing data to Shopify haha
yeah, if you are able to connect locally to a test or staging environment, It would be interesting to see what errors you get line by line. Besides that I’m not sure If I can offer any additional suggests.
Do you have a sample of a method you’re using at all?
Basically it seems that the issue is the graphQL query is what’s causing the error in my code. If I move it outside the method I can run it, but then I am getting the error about setting the API version.
You must set ShopifyAPI::Base.api_version before making a request.
Im thinking I need to set the credentials elsewhere, so its global and can be accessed.
Man the REST API was so easy to use haha, this is all new to me.
I was wondering how I would call it and create this automatically for each merchant store that signs up. Maybe each time a store is created, I should run this task? By using something like this inside the model?