Solved

GraphQL query some products return null.

eaboy
Visitor
2 0 2

Hi I'm Eduardo.

I'm currently working with the GraphQL Storefront API and I'm facing an issue and need some help with it. Basically I'm doing a request of products based on the product ids and for most of the products works fine but there are some that are returning a null node. I've tried the exact same request in the Shopify GraphiQL App and there I'm getting the correct data, no null nodes. Also checked and the product ids are correct. What could be happening here?

This is the query:

 

 

query SpecificProduct($ids: [ID!]!) {
  nodes(ids: $ids) {
    ... on Product {
      id
      title
      handle
      tags
      images(first: 1) {
        edges {
          node {
            src
          }
        }
      }
      variants(first: 100) {
        edges {
          node {
            price
            id
            sku
            title
            compareAtPrice
          }
        }
      }
    }
  }
}

 

 

And as variables, I pass an array of encoded gids.

In the response, some of the nodes have correct product data but some are null.

Any help will be appreciated. 

 

Accepted Solution (1)

c10s
Shopify Partner
67 12 26

This is an accepted solution.

Might be that the products returning null aren't available on the relevant sales channel (your Storefront API channel). Can double check it on the edit product page in the Shopify admin.

View solution in original post

Replies 4 (4)

c10s
Shopify Partner
67 12 26

This is an accepted solution.

Might be that the products returning null aren't available on the relevant sales channel (your Storefront API channel). Can double check it on the edit product page in the Shopify admin.

eaboy
Visitor
2 0 2

Thanks @c10s  it was just that. Those products were not added to the channel. 

den232
Shopify Partner
192 8 52

Just for the record, the products also have to be active.  I imported a bunch and they didn't show ... that was the problem for me.  Cheers jb

Shu-Miyao
Shopify Partner
3 0 2

Thanks a lot. Your hint helped me indeed.

 

My case was that there are only 2 products returned though there are about 100 of items with a few variations each. They were recently imported by a client and no sales channels were selected at all.

 

ScreenShot 2023-01-24 at 2.02.48 PM.JPG