App reviews, troubleshooting, and recommendations
Does anyone have an example of how to execute a query to Shopify Admin API using GraphQL? I see the example on the Shopify Admin docs (https://shopify.dev/api/admin-graphql#client_libraries), but I am not sure where this code should be written and if I am missing any type of import statements, etc. I have created the default tempalte app using "shopify app create node" command, but can't seem to get a simple query to work. Please help!
Here is the sample code on the Shopfy Admin Doc website:
const queryString = `{
products (first: 3) {
edges {
node {
id
title
}
}
}
}`
// `session` is built as part of the OAuth process
const client = new Shopify.Clients.Graphql(
session.shop,
session.accessToken
);
const products = await client.query({
data: queryString,
});
Hi @nathan-help do you see any specific errors?
Try referencing https://github.com/Shopify/shopify-node-api/blob/main/docs/usage/graphql.md
I'd suggest following the dev doc's `Build and app example` first to build up your foundations: https://shopify.dev/apps/getting-started/build-app-example
The backend section has a more in-depth example of query usage
https://shopify.dev/apps/getting-started/build-app-example/backend#step-2-add-the-api-layer
If your familiar with the insomnia rest client that has an export feature for things like curl to then adapt
Goodluck!
Contact paull.newton+shopifyforum@gmail.com for the solutions you need
Save time & money ,Ask Questions The Smart Way
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Thank Paul with a ☕ Coffee for more answers or donate to eff.org
Hi Paul,
Thanks for the response. Here is my code:
I get the following error: "Uncaught TypeError: Buffer2 is undefined"
This error occurs with the import statement import { Shopify } from "@shopify/shopify-api";
even without making the call to testQuery.
I am not sure if there is something wrong with the dependencies, but I just created the app with the 'shopify create app node' command in the terminal.
Did you ever resolve this? Facing a similar problem...
In Canada, payment processors, like those that provide payment processing services t...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025