query a lot of data at once without bulk

Solved

query a lot of data at once without bulk

AW1234
Shopify Partner
44 7 12

Hello,

 

I have hundreds of fulfillmentOrder ids and I have to query some data as:

{
      nodes(ids: [${ids.splice(0, 250).map((id) => `"${id}"`)}]) {
        ... on FulfillmentOrder {
          id,
          lineItems(first:150) {
            nodes {
              id, remainingQuantity, totalQuantity, sku
            }
          }
          fulfillments(first:10) {
            nodes {
              id
              trackingInfo {
                number
              }
              fulfillmentLineItems(first:150) {
                nodes{
                  quantity,
                  lineItem {
                    sku
                  }
                }
              }
            }
          }
        }
      }
    }

The problem is that this costs too much of query cost, can't query more than 1 000 query cost (first of all I don't understand this limit as I have 10 000 available),

I tried it by a bulk query but it returns errors:

Queries that contain a connection field within a list field are not currently supported

Bulk queries cannot contain more than 5 connections

I also tried it with aliases, it didn't work neither.

Is there a way to make this query work or do I really have to make multiple query for every ids?

Thanks in advance.

Accepted Solution (1)
AW1234
Shopify Partner
44 7 12

This is an accepted solution.

I did some changes and it works for the moment, instead of re-querying for fulfillmentOrders I take fulfillments ids and query nodes on Fulfillment

like this

{
        nodes(ids: [${splicedIds.map((id) => `"${id}"`)}]) {
          ... on FulfillmentOrder {
            id,
            lineItems(first:150) {
              nodes {
                id, remainingQuantity, totalQuantity, sku
              }
            }
            fulfillments(first:15) {
              nodes {
                id
              }
            }
          }
        }
      }

in js I just take the fulfillment ids with 

ffOrders.map((ffOrder) => ffOrder.fulfillments.nodes.map((f) => f.id)).flat();

and then I query for Fulfillment

{
        nodes(ids: [${ffIds.splice(0, 250).map((id) => `"${id}"`)}]) {
          ... on Fulfillment {
            id
            trackingInfo {
              number
            }
            fulfillmentLineItems(first:150) {
              nodes{
                quantity,
                lineItem {
                  sku
                }
              }
            }
          }
        }
      }

I post it if someone, noob on graphql like me, needs

 

View solution in original post

Replies 2 (2)

AW1234
Shopify Partner
44 7 12

Hello,

I tried to make 2 queries as

{
        nodes(ids: [${splicedIds.map((id) => `"${id}"`)}]) {
          ... on FulfillmentOrder {
            id,
            lineItems(first:150) {
              nodes {
                id, remainingQuantity, totalQuantity, sku
              }
            }
            fulfillments(first:15) {
              nodes {
                id
                trackingInfo {
                  number
                }
              }
            }
          }
        }
      }

and

{
        nodes(ids: [${splicedIds.map((id) => `"${id}"`)}]) {
          ... on FulfillmentOrder {
            fulfillments(first:15) {
              nodes {
                id
                fulfillmentLineItems(first:150) {
                  nodes{
                    quantity,
                    lineItem {
                      sku
                    }
                  }
                }
              }
            }
          }
        }
      }

The first one is ok but the other has MAX_COST_EXCEEDED problem, can someone help on this pls?

AW1234
Shopify Partner
44 7 12

This is an accepted solution.

I did some changes and it works for the moment, instead of re-querying for fulfillmentOrders I take fulfillments ids and query nodes on Fulfillment

like this

{
        nodes(ids: [${splicedIds.map((id) => `"${id}"`)}]) {
          ... on FulfillmentOrder {
            id,
            lineItems(first:150) {
              nodes {
                id, remainingQuantity, totalQuantity, sku
              }
            }
            fulfillments(first:15) {
              nodes {
                id
              }
            }
          }
        }
      }

in js I just take the fulfillment ids with 

ffOrders.map((ffOrder) => ffOrder.fulfillments.nodes.map((f) => f.id)).flat();

and then I query for Fulfillment

{
        nodes(ids: [${ffIds.splice(0, 250).map((id) => `"${id}"`)}]) {
          ... on Fulfillment {
            id
            trackingInfo {
              number
            }
            fulfillmentLineItems(first:150) {
              nodes{
                quantity,
                lineItem {
                  sku
                }
              }
            }
          }
        }
      }

I post it if someone, noob on graphql like me, needs