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.

how to query correct with pagination in graphql

how to query correct with pagination in graphql

hmjeh
Tourist
11 3 0

i try to query for 200 items and because of the restrict on cost of query i need to use  pagination in  i do while loop

 

 

 

 

pagination = response.data.data.orders.pageInfo['hasNextPage']

 

 

 

 

 while pagination=true

 

 

 

 

 

let pagination=true
let data =[]
let response=[]
let cursor=null
  
while (pagination)
  const getdata=async(cursor)=>{
    response.push(await axios.post(
      `${SHOPIFYURL}`,
       {query: `
     query {
       orders(first:33,after:${cursor},query:"fulfillment_status:unfulfilled 
       AND 
       shippingAddress.country:United States 
       AND 
       -tag:'handdle'"){
         edges {
           node {
             id
             tags
             displayFulfillmentStatus
             shippingAddress {
               address1
               city
               country
               firstName
               lastName
               phone
               provinceCode
               zip
             }
             lineItems(first: 7) {
               nodes {
                 quantity
                 product {
                   id
                 }
                 variant {
                   sku
                 }
               }
             }
             fulfillmentOrders(first: 3, reverse: true) {
               nodes {
                 id
               }
             }
           }
         }
         pageInfo {
         hasNextPage
         endCursor
         }
       }
     }
     `},
     
     {headers: {'X-Shopify-Access-Token':process.env.Access_Token, 'Content-Type': 'application/json'}}
   ))

   pagination = response.data.data.orders.pageInfo['hasNextPage']
   cursor=`"${response.data.data.orders.pageInfo['endCursor']}"`
   avalabe = [...data,...response.data.data.orders.edges]
   
  
return[avalabe]
  }

 

 

 

 

And I received the first 33 products

But I got an error on the rest

 

 

 

 

 errors: [ { message: 'Throttled', extensions: [Object] } ],

 

 

 

 

I read about it and as far as I understand it is because I am also limited in the time of the queries


 
I need help on how to do the query correctly so that I won't be missing products because of the restriction

 

Replies 0 (0)