Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
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
Solved! Go to the solution
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'); }); }); }); }); });
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'); }); }); }); }); });
@codemonkey is this solution still working for you?
It was working fine for us as well, but for the last couple of weeks, it's not returning any shippingRates.
@Cleankitchen I actually ended up switching to Apollo GraphQL client so I'm unsure if this solution works any longer.