Re: Shopify function input GraphQL exceeds max complexity

Solved

Shopify function input GraphQL exceeds max complexity

JackLin_PG
Shopify Partner
7 0 1

I am developing to cart transform of shopify function and got the error from run.graphql.
Is there any way to set complexity bigger?

Error message: Error while updating drafts: Query has complexity of 33, which exceeds max complexity of 30
run.graphql: 

query RunInput {
  cart {
    buyerIdentity {
      email
      customer {
        L2101: hasAnyTag(tags: ["L2101"])
        L2102: hasAnyTag(tags: ["L2102"])
        L2103: hasAnyTag(tags: ["L2103"])
        L1101: hasAnyTag(tags: ["L1101"])
        L1102: hasAnyTag(tags: ["L1102"])
        L1103: hasAnyTag(tags: ["L1103"])
      }
    }
    lines {
      id
      quantity
      cost {
        totalAmount {
          amount
          currencyCode
        }
      }
      merchandise {
        __typename
        ... on ProductVariant {
          id
          sku
          title
          product {
            productType
            title
          }
        }
      }
    }
  }
  shop {
    productRule: metafield(namespace: "productRule", key: "productRule") {
      value
    }
  }
}

 

 
Accepted Solution (1)
jbourassa
Shopify Staff (Retired)
11 2 2

This is an accepted solution.

You can use `Customer.hasTags` to grab multiple tags in a single field.

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 3 (3)

jam_chan
Shopify Partner
915 23 187

Can you merge the customer query to reduce complexity?

customer {
        L2101: hasAnyTag(tags: ["L2101"])
        L2102: hasAnyTag(tags: ["L2102"])
        L2103: hasAnyTag(tags: ["L2103"])
        L1101: hasAnyTag(tags: ["L1101"])
        L1102: hasAnyTag(tags: ["L1102"])
        L1103: hasAnyTag(tags: ["L1103"])
      }
BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview
JackLin_PG
Shopify Partner
7 0 1

How to merge them? I would like to get what tag the customer has.

thanks

jbourassa
Shopify Staff (Retired)
11 2 2

This is an accepted solution.

You can use `Customer.hasTags` to grab multiple tags in a single field.

To learn more visit the Shopify Help Center or the Community Blog.