Out now! Check out the Poll results: Do you have a Shopify store?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: Slow loading products through GraphQL API

Slow loading products through GraphQL API

Kevin64
Shopify Partner
10 0 0

Using Unity SDK, but ultimately under the hood it is just a GraphQL call to request products data. Not the images, just the JSON associated with the product details and variants. Using high speed internet, and trying PC, iOS, and Android, I'm still seeing things take nearly a second per product. That means to load a category with 10 products, the user has to wait 10 seconds on our app. Not gonna work.

 

I'm hitting the 2019-10 API with a standard request for basic product data. Has anyone else seen this or gotten around it?

 

 

Note: my last post regarding this topic was marked as spam. So I'm trying it again.

Replies 4 (4)

SBD_
Shopify Staff
1831 273 421

Hey @Kevin64,

 

Are you able to provide a request ID from the headers of one of these requests?

Scott | Developer Advocate @ Shopify 

Kevin64
Shopify Partner
10 0 0

@SBD_ Just ran a query a moment ago and got this X-Response-ID: "8b2eac4b-f540-4d54-b7fb-6046245b5c20"

 

Here are the content headers:Content Headers.png

Here is the contents of my GraphQL Query:

 

"{nodes (ids:[\"<product-IDs>"]){__typename ...on Product{id title description descriptionHtml options {name values }variants (first:250){edges {node {id availableForSale image {altText transformedSrc transformedSrc___pico:transformedSrc (maxWidth:16,maxHeight:16)transformedSrc___icon:transformedSrc (maxWidth:32,maxHeight:32)transformedSrc___thumb:transformedSrc (maxWidth:50,maxHeight:50)transformedSrc___small:transformedSrc (maxWidth:100,maxHeight:100)transformedSrc___compact:transformedSrc (maxWidth:160,maxHeight:160)transformedSrc___medium:transformedSrc (maxWidth:240,maxHeight:240)transformedSrc___large:transformedSrc (maxWidth:480,maxHeight:480)transformedSrc___grande:transformedSrc (maxWidth:600,maxHeight:600)transformedSrc___resolution_1024:transformedSrc (maxWidth:1024,maxHeight:1024)transformedSrc___resolution_2048:transformedSrc (maxWidth:2048,maxHeight:2048)}price title weight selectedOptions {name value }metafields (first:250){edges {node {description id key namespace value valueType }cursor }pageInfo {hasNextPage }}weightUnit }cursor }pageInfo {hasNextPage }}collections (first:250){edges {node {id title updatedAt }cursor }pageInfo {hasNextPage }}images (first:250){edges {node {altText transformedSrc transformedSrc___pico:transformedSrc (maxWidth:16,maxHeight:16)transformedSrc___icon:transformedSrc (maxWidth:32,maxHeight:32)transformedSrc___thumb:transformedSrc (maxWidth:50,maxHeight:50)transformedSrc___small:transformedSrc (maxWidth:100,maxHeight:100)transformedSrc___compact:transformedSrc (maxWidth:160,maxHeight:160)transformedSrc___medium:transformedSrc (maxWidth:240,maxHeight:240)transformedSrc___large:transformedSrc (maxWidth:480,maxHeight:480)transformedSrc___grande:transformedSrc (maxWidth:600,maxHeight:600)transformedSrc___resolution_1024:transformedSrc (maxWidth:1024,maxHeight:1024)transformedSrc___resolution_2048:transformedSrc (maxWidth:2048,maxHeight:2048)}cursor }pageInfo {hasNextPage }}metafields (first:250){edges {node {description id key namespace value valueType }cursor }pageInfo {hasNextPage }}}}"

Hitting the URL: https://dimensionally-yours.myshopify.com/api/2019-10/graphql.json

Kevin64
Shopify Partner
10 0 0

@SBD_ Just following up with this. Any thoughts?

SBD_
Shopify Staff
1831 273 421

Hey @Kevin64 

 

Thanks for the request ID. That's quite a large query returning ~1MB of data. Testing from my end, the first query took about 5 seconds, and repeat queries about one second. 


To improve the performance:

- How often does this data change? Can you cache anything on your end?

- Are you using all the information that you're querying for? Perhaps the query complexity can be reduced?

- Is all the data used at once? I.e. could you break up the query as the user moves through the app?

 

 

Scott | Developer Advocate @ Shopify