Nodes and filter GraphQL

Highlighted
New Member
14 0 0

We have a database that holds many of the product variants from Shopify stores.

 

We want to get a list of updated products variants from Shopify, but for only the ones that have matching product variant id's in our database.

 

This because the Shopify store might have a huge number of product variants, and e are just interested in the ones we have in our database.

 

Have used this query:

 

query {
  nodes(ids:["gid://shopify/ProductVariant/31319076274311","gid://shopify/ProductVariant/31319076339847"]) {
    ... on ProductVariant {
      id
      sku
      title
      inventoryQuantity
      product {
        id
        title
        vendor
      }
      inventoryItem {
        id
        inventoryLevels(first: 1) {
          edges {
            node {
              id
              available
              location {
                id
              }
            }
          }
        }
      }
      updatedAt
    }
  }
}

Of course in the real code the id's are not hard coded, but in a variable.

 

In one instance this takes 6-7 seconds to load. (with real data of around 1500 product variants).

 

Is it possible to put a filter on this so that it will only return updated_at >= a date ? So that it returns maybe 50 instead of 1500.

 

And yes, we are aware that we can use this filter without nodes, but again this might return a huge number of product variants that we have no use of since they might not be in our database.

0 Likes