Graphql request with shopify node client

Shopify Partner
3 0 1

Hi all, I am having a rough time making a simple graphql query from my basic node app. I keep getting:

"Error in /checkout-update: TypeError: Cannot read properties of undefined (reading 'query')"


const { shopifyApi, LATEST_API_VERSION } = require('@shopify/shopify-api');
const express = require('express');
const bodyParser = require('body-parser');

const app = express();
app.use(bodyParser.raw({ type: 'application/json' }));

try {
  const shopify = shopifyApi({
    apiKey: process.env.API_KEY,
    apiSecretKey: process.env.API_SECRET_KEY,
    scopes: ['read_checkouts', 'unauthenticated_read_product_listings'],
    hostName: `${process.env.SHOP_NAME}`,
    apiVersion: LATEST_API_VERSION,
    privateAppStorefrontAccessToken: process.env.STOREFRONT_ACCESS_TOKEN
  });'/checkout-update', async (req, res) => {
    try {
      const rawData = req.body.toString('utf8');
      const parsedData = JSON.parse(rawData);
      const checkoutId =;
      console.log('Captured checkout ID:', checkoutId);

      const storeQuery = `
        query {
          shop {

      const storeResponse = await shopify.graphQLClient.query({
        query: storeQuery,

      console.log('Store Name:',;

      // Query for first 3 products via the Storefront API
      const productQuery = `
        query {
          products (first: 3) {
            edges {
              node {

      const productResponse = await shopify.graphQLClient.query({
        query: productQuery,

      console.log('First 3 Products:',;

    } catch (innerErr) {
      console.error('Error in /checkout-update:', innerErr);

  app.listen(3003, () => {
    console.log('Server is running on port 3003');
} catch (outerErr) {
  console.error('Error in setting up Shopify API:', outerErr);



Any help would be appreciated. Willing to compensate you for your time, feel free to DM.

Reply 1 (1)

Shopify Staff
1322 218 457

Hey @mikesynan

Thank you for bringing this issue to our attention. If this problem pertains to our Node library, I recommend referring to our GitHub repository. It contains a wealth of information that could potentially help you resolve the issue. Here is the link to the repository:

In addition to that you might find it beneficial to step through the process using an API client, such as our Graphiql app. This can assist in pinpointing whether the issue lies within your specific API queries or if it's related to the Node implementation itself.

Hope that helps! 

- Kyle G.

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit or the Shopify Web Design and Development Blog