user9722
user9722

Reputation: 171

Change Graphql query so it will display each product on a separate row

Tl;Dr: I need to change my Graphql query so it will display each product on a separate row with it's 'rateProvider' (or shipping rate) data in columns next to it.


I'm retrieving Shopify API data using the query below in Google Sheets using The API Connector add-on and following the instructions here for GraphQL: https://mixedanalytics.com/knowledge-base/access-shopify-data-in-google-sheets/

The query retrieves Shopify products and their delivery profile. But all products are being displayed in a single row based on their delivery profile? For instance, if 10 products are in delivery profile ($100 Shipping) then all 10 products for that delivery profile would appear in a single row together with their delivery profile data like first example below.

But I want each product to be displayed on separate rows with the delivery profile data in the columns beside it like the second example below *I am also not sure of how to setup the proper pagination for this query to pull 'all products'.

Example 1:
product #1 | product #2 | deliveryProfile ($100 shipping)
product #1 | product #2 | deliveryProfile ($50 shipping)

Example: 2:
product #1 | deliveryProfile ($100 shipping)
product #2 | deliveryProfile ($100 shipping)
product #1 | deliveryProfile ($50 shipping)
product #2 | deliveryProfile ($50 shipping)

query ($cursor: String) {
  deliveryProfiles (first: 5) {
    edges {
      node {
        profileItems (first: 5, after: $cursor) {
          edges {
           cursor
            node {
              product {
                id
                handle
              }
              variants (first: 5) {
                edges {
                  node {
                    id
                    title
                  }
                }
              }
            }
          }
        }
        profileLocationGroups {
          locationGroupZones(first: 5) {
            edges {
              node {
                methodDefinitions(first: 5) {
                  edges {
                    node {
                      rateProvider {
                        ... on DeliveryRateDefinition {
                          id
                          price {
                            amount
                          }
                        }
                        ... on DeliveryParticipant {
                          id
                          fixedFee {
                            amount
                            currencyCode
                          }
                          percentageOfRateFee
                          participantServices {
                            active
                            name
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }        
      }
    }
  }
}

Upvotes: 1

Views: 531

Answers (1)

user9722
user9722

Reputation: 171

Solved: If you are using the API Connector (Add-On) for Google Sheets to import data from Shopify AND you are using a GraphQL Query you have to go into the API Connector's [Output Options] menu and change Report style to [Compact] to display the individual records on their own rows.

Upvotes: 0

Related Questions