Solved

Question about getting pricing policies in selling plan groups

d_tehrani
Shopify Partner
56 1 13

 

 

 

query ($id: ID!) {
  sellingPlanGroup(id: $id) {
    id
    sellingPlans(first: 1) {
      edges {
        node {
          id
          pricingPolicies {
            ... on SellingPlanFixedPricingPolicy {
              adjustmentType
              adjustmentValue {
                ... on SellingPlanPricingPolicyPercentageValue {
                  percentage
                }
              }
            }
            ... on SellingPlanRecurringPricingPolicy {
              adjustmentType
              afterCycle
              adjustmentValue {
                ... on SellingPlanPricingPolicyPercentageValue {
                  percentage
                }
              }
            }
          }
        }
      }
    }
  }
}

 

 

 

When I run the above query, I get this weird warning, and I cannot fetch the data I want because of it.

WARNING: heuristic fragment matching going on!
┃ Missing field afterCycle in {
┃ "adjustmentType": "PERCENTAGE",
┃ "adjustmentValue": {
┃ "percentage": 11,
┃ "__typename": "

 

 

 

 

query ($id: ID!) {
  sellingPlanGroup(id: $id) {
    id
    sellingPlans(first: 1) {
      edges {
        node {
          id
          pricingPolicies {
            ... on SellingPlanRecurringPricingPolicy {
              adjustmentType
              afterCycle
              adjustmentValue {
                ... on SellingPlanPricingPolicyPercentageValue {
                  percentage
                }
              }
            }
          }
        }
      }
    }
  }
}

 

 

 

 

And when I modify the query, for example as above, I get a different warning as below, even though SellingPlanFixedPricingPolicy does not have afterCycle as a field.

WARNING: heuristic fragment matching going on!
┃ Missing field adjustmentType in {
┃ "__typename": "SellingPlanFixedPricingPolicy"
┃ }
┃ Missing field afterCycle in {
┃ "__typename": "SellingPlanFixedPricingPolicy"
┃ }
┃ Missing field adjustmentValue in {
┃ "__typename": "SellingPlanFixedPricingPolicy"
┃ }


I would appreciate it if someone could tell me if I'm missing something here.

Accepted Solution (1)
d_tehrani
Shopify Partner
56 1 13

This is an accepted solution.

Thanks for the reply.

That didn't work, but when I switched to @Apollo/client^3.3.11 from apollo-boost^0.4.9, it worked without the code you posted. So I guess it was a client issue.

View solution in original post

Replies 5 (5)

qc11
Shopify Staff (Retired)
47 14 12

Hi, I do not see any errors in the original query you shared.
Tested on my end and it's working.

Do you think there might be something missing on the graphql client side?

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

d_tehrani
Shopify Partner
56 1 13

Hi. Thanks for the reply.

I configured my client according to this article, but I still get the same warning.

 

My client

const cache = new InMemoryCache({
    possibleTypes: {"AppPricingDetails":["AppRecurringPricing","AppUsagePricing"],"AppPurchase":["AppPurchaseOneTime"],"CalculatedDiscountApplication":["CalculatedAutomaticDiscountApplication","CalculatedDiscountCodeApplication","CalculatedManualDiscountApplication","CalculatedScriptDiscountApplication"],"CommentEventEmbed":["Customer","DraftOrder","Order","Product","ProductVariant"],"CommentEventSubject":["Customer","DraftOrder","Order","PriceRule"],"CustomerMoment":["CustomerVisit"],"CustomerPaymentInstrument":["CustomerCreditCard"],"DeliveryConditionCriteria":["MoneyV2","Weight"],"DeliveryRateProvider":["DeliveryParticipant","DeliveryRateDefinition"],"DiscountApplication":["AutomaticDiscountApplication","DiscountCodeApplication","ManualDiscountApplication","ScriptDiscountApplication"],"DiscountAutomatic":["DiscountAutomaticBasic","DiscountAutomaticBxgy"],"DiscountCode":["DiscountCodeBasic","DiscountCodeBxgy","DiscountCodeFreeShipping"],"DiscountCustomerBuysValue":["DiscountPurchaseAmount","DiscountQuantity"],"DiscountCustomerGetsValue":["DiscountAmount","DiscountOnQuantity","DiscountPercentage"],"DiscountCustomerSelection":["DiscountCustomerAll","DiscountCustomerSavedSearches","DiscountCustomers"],"DiscountEffect":["DiscountPercentage"],"DiscountItems":["AllDiscountItems","DiscountCollections","DiscountProducts"],"DiscountMinimumRequirement":["DiscountMinimumQuantity","DiscountMinimumSubtotal"],"DiscountShippingDestinationSelection":["DiscountCountries","DiscountCountryAll"],"DisplayableError":["BillingAttemptUserError","CustomerPaymentMethodUserError","DiscountUserError","FulfillmentOrderRescheduleUserError","MediaUserError","PriceRuleUserError","ProductChangeStatusUserError","SellingPlanGroupUserError","ShopPolicyUserError","SubscriptionContractUserError","SubscriptionDraftUserError","TranslationUserError","UserError"],"Event":["BasicEvent","CommentEvent"],"HasEvents":["Customer","DiscountAutomaticBxgy","DiscountAutomaticNode","DiscountCodeNode","DraftOrder","Order","PriceRule"],"HasLocalizationExtensions":["Order"],"HasLocalizationExtensionsForDraftOrders":["DraftOrder"],"HasMetafields":["Collection","Customer","DraftOrder","Image","Order","Product","ProductVariant","Shop"],"HasPublishedTranslations":["Collection","Link","OnlineStoreArticle","OnlineStoreBlog","OnlineStorePage","Product","ProductOption","ProductVariant","Shop","ShopPolicy"],"LegacyInteroperability":["Customer","DraftOrder","Fulfillment","InventoryItem","Location","MarketingEvent","Metafield","MetafieldStorefrontVisibility","Order","PriceRule","Product","ProductVariant","Refund","SavedSearch","ScriptTag","ShopifyPaymentsDispute","ShopifyPaymentsPayout","WebhookSubscription"],"Media":["ExternalVideo","MediaImage","Model3d","Video"],"Navigable":["OnlineStoreArticle","OnlineStorePage","Product","ProductVariant"],"Node":["App","AppCredit","AppInstallation","AppPurchaseOneTime","AppSubscription","AppUsageRecord","BasicEvent","BulkOperation","CalculatedOrder","Channel","Collection","CommentEvent","Customer","CustomerPaymentMethod","CustomerVisit","DeliveryCarrierService","DeliveryCondition","DeliveryCountry","DeliveryLocationGroup","DeliveryMethod","DeliveryMethodDefinition","DeliveryParticipant","DeliveryProfile","DeliveryProvince","DeliveryRateDefinition","DeliveryZone","DiscountAutomaticBxgy","DiscountAutomaticNode","DiscountCodeNode","Domain","DraftOrder","DraftOrderLineItem","Duty","ExternalVideo","Fulfillment","FulfillmentEvent","FulfillmentLineItem","FulfillmentOrder","FulfillmentOrderDestination","FulfillmentOrderLineItem","FulfillmentOrderMerchantRequest","InventoryItem","InventoryLevel","LineItem","LineItemMutable","Location","MailingAddress","MarketingActivity","MarketingEvent","MediaImage","Metafield","MetafieldStorefrontVisibility","Model3d","OnlineStoreArticle","OnlineStoreBlog","OnlineStorePage","Order","OrderDisputeSummary","OrderTransaction","PriceRule","PriceRuleDiscountCode","PrivateMetafield","Product","ProductOption","ProductVariant","Publication","Refund","SavedSearch","ScriptTag","SellingPlan","SellingPlanGroup","Shop","ShopPolicy","ShopifyPaymentsAccount","ShopifyPaymentsBankAccount","ShopifyPaymentsDispute","ShopifyPaymentsPayout","ShopifyPaymentsVerification","StorefrontAccessToken","SubscriptionBillingAttempt","SubscriptionContract","SubscriptionDraft","TenderTransaction","TransactionFee","Video","WebhookSubscription"],"OnlineStorePreviewable":["Product"],"OrderStagedChange":["OrderStagedChangeAddCustomItem","OrderStagedChangeAddLineItemDiscount","OrderStagedChangeAddShippingLine","OrderStagedChangeAddVariant","OrderStagedChangeDecrementItem","OrderStagedChangeIncrementItem"],"PriceRuleValue":["PriceRuleFixedAmountValue","PriceRulePercentValue"],"PricingValue":["MoneyV2","PricingPercentageValue"],"Publishable":["Collection","Product"],"SellingPlanBillingPolicy":["SellingPlanRecurringBillingPolicy"],"SellingPlanDeliveryPolicy":["SellingPlanRecurringDeliveryPolicy"],"SellingPlanPricingPolicy":["SellingPlanFixedPricingPolicy","SellingPlanRecurringPricingPolicy"],"SellingPlanPricingPolicyAdjustmentValue":["MoneyV2","SellingPlanPricingPolicyPercentageValue"],"SellingPlanPricingPolicyBase":["SellingPlanFixedPricingPolicy","SellingPlanRecurringPricingPolicy"],"ShopifyPaymentsChargeStatementDescriptor":["ShopifyPaymentsDefaultChargeStatementDescriptor","ShopifyPaymentsJpChargeStatementDescriptor"],"SubscriptionDeliveryMethod":["SubscriptionDeliveryMethodShipping"],"SubscriptionDiscount":["SubscriptionAppliedCodeDiscount","SubscriptionManualDiscount"],"SubscriptionDiscountValue":["SubscriptionDiscountFixedAmountValue","SubscriptionDiscountPercentageValue"],"SubscriptionShippingOptionResult":["SubscriptionShippingOptionResultFailure","SubscriptionShippingOptionResultSuccess"],"TenderTransactionDetails":["TenderTransactionCreditCardDetails"],"WebhookSubscriptionEndpoint":["WebhookEventBridgeEndpoint","WebhookHttpEndpoint"]}
  })

  new ApolloClient({
        uri: `https://${shop}/admin/api/2021-01/graphql.json`,
        cache,
        request: operation => {
          operation.setContext({
            headers: {
              "X-Shopify-Access-Token": accessToken,
              "User-Agent": `shopify-app-node ${
                process.env.npm_package_version
              } | Shopify App CLI`
            }
          });
        }
      })

 

I'm using apollo-boost^0.4.9 which came with Shopify App CLI v1.5.0.
Is there anything that I need to configure?

 

Thanks.

 

qc11
Shopify Staff (Retired)
47 14 12

Hi! I'm sorry I really want to be more helpful but I'm not really an expert in terms of setting up Graphql client.

Maybe try asking here https://community.shopify.com/c/Shopify-APIs-SDKs/bd-p/shopify-apis-and-technology instead to see if there are anyone who have experience could give you some tips?

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

ThomazReis
Shopify Staff
24 10 6

Hi!

I think you could try adding:

            ... on SellingPlanFixedPricingPolicy { ...
            }

 Inside SellingPlans

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

d_tehrani
Shopify Partner
56 1 13

This is an accepted solution.

Thanks for the reply.

That didn't work, but when I switched to @Apollo/client^3.3.11 from apollo-boost^0.4.9, it worked without the code you posted. So I guess it was a client issue.