GraphQL Shopify-Buy SDK retrieve available shipping rates with checkout

Solved
Excursionist
12 1 0

I'm attempting to use the Shopify Buy SDK to create a checkout and look up the available shipping rates for that checkout. How do I add the available shipping rates selection to the query? addConnection appears to be used for paginated data (like products, variants, or images). 

 

const query = this.client.graphQLClient.query((root) => {
  root.add('node', { args: {id: checkout_id} }, (node) => {
    node.add('id');
    node.addInlineFragmentOn('Checkout', (checkout) => {
      checkout.add('totalPrice');
      checkout.addConnection('availableShippingRates', (rate) => {
        rate.add('title');
      });
    });
  });
});

return this.client.graphQLClient.send(query).then(({ model, data }) => {
  return data;
});

gives me the error:

ERROR Error: Uncaught (in promise): Error: No field of name "pageInfo" found on type "AvailableShippingRates" in schema
Error: No field of name "pageInfo" found on type "AvailableShippingRates" in schema

 

0 Likes
Highlighted
Excursionist
12 1 0

This is an accepted solution.

For those curious, here's what I found that works:

    const query = this.client.graphQLClient.query((root) => {
      root.add('node', { args: {id: checkout_id} }, (node) => {
        node.add('id');
        node.addInlineFragmentOn('Checkout', (checkout) => {
          checkout.add('totalTax');
          checkout.add('taxesIncluded');
          checkout.add('taxExempt');
          checkout.add('subtotalPrice');
          checkout.add('totalPrice');
          checkout.add('email');
          checkout.add('createdAt');
          checkout.add('webUrl');
          checkout.add('requiresShipping');
          checkout.add('availableShippingRates', (rates) => {
            rates.add('ready');
            rates.add('shippingRates', (rate) => {
              rate.add('title');
              rate.add('price');
              rate.add('handle');
            });
          });
        });
      });
    });
0 Likes