Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[api-codegen-preset] Cannot query field "delivery" on type "Cart" and more+ "discountApplication" on type "CartCodeDiscountAllocation" #1965

Closed
3 of 5 tasks
TheMechanic opened this issue Jan 15, 2025 · 1 comment
Assignees

Comments

@TheMechanic
Copy link

TheMechanic commented Jan 15, 2025

Issue summary

Before opening this issue, I have:

  • Upgraded to the latest version of the relevant packages
    • @shopify/* package and version:
    • Node version: v20.12.2
    • Operating system: MacOs 15.2 (24C101)
  • Set { logger: { level: LogSeverity.Debug } } in my configuration, when applicable
  • Found a reliable way to reproduce the problem that indicates it's a problem with the package
  • Looked for similar issues in this repository
  • Checked that this isn't an issue with a Shopify API

Hi ! I'm getting some issues generating my types. Note than the request itself works perfectly, it's just about types generations. If i comment the delivery / discountApplication parts, it works. Could anyone help ? thanks a lot !

`Generate to ./src/platform/shopifyv2/storefront-types/storefront.generated.ts

✔ Load GraphQL schemas
✔ Load GraphQL documents
✖ GraphQL Document Validation failed with 4 errors;
  Error 0: Cannot query field "delivery" on type "Cart".
  at /src/platform/shopifyv2/commons/mutations/create-cart.ts:23:11
  Error 1: Unknown type "CartDeliveryAddress". Did you mean "DeliveryAddress", "CartDeliveryGroup", "CartDeliveryOption", "CartDeliveryGroupEdge", or …
  at /shopifyv2/commons/mutations/create-cart.ts:26:23
  Error 2: Cannot query field "discountApplication" on type "CartCodeDiscountAllocation".
  at /shopifyv2/commons/mutations/create-cart.ts:44:8
  Error 3: Cannot query field "discountApplication" on type "CartCodeDiscountAllocation".
  at /shopifyv2/commons/mutations/create-cart.ts:98:11`

here is my conf :

Image

and here is my mutation query cart :

export const createCartMutation = `#graphql
  mutation cartCreate($input: CartInput!) {
    cartCreate(input: $input) {
      cart {
        id
        appliedGiftCards {
          amountUsed {
            amount
            currencyCode
          }
          lastCharacters
          id
        }
        attributes {
          key
          value
        }
        checkoutUrl
        buyerIdentity {
          email
          phone
        }
        delivery {
          addresses {
            address {
              ... on CartDeliveryAddress {
                address1
                address2
                city
                countryCode
                firstName
                lastName
                phone
                provinceCode
                zip
              }
            }
          }
        }
        discountAllocations {
          ... on CartCodeDiscountAllocation {
            __typename
            code
            discountApplication {
              targetSelection
              value {
                ... on MoneyV2 {
                  __typename
                  amount
                  currencyCode
                }
                ... on PricingPercentageValue {
                  __typename
                  percentage
                }
              }
            }
          }
          targetType
        }
        discountCodes {
          applicable
          code
        }
        deliveryGroups(first: 50) {
          edges {
            node {
              id
              deliveryOptions {
                handle
                title
                estimatedCost {
                  amount
                }
              }
              selectedDeliveryOption {
                handle
                title
                estimatedCost {
                  amount
                }
              }
            }
          }
        }
        lines(first: 10) {
          edges {
            node {
              id
              quantity
              attributes {
                key
                value
              }
              discountAllocations {
                targetType
                ... on CartCodeDiscountAllocation {
                  discountApplication {
                    targetSelection
                    value {
                      ... on MoneyV2 {
                        amount
                        currencyCode
                      }
                      ... on PricingPercentageValue {
                        percentage
                      }
                    }
                  }
                }
              }
              merchandise {
                __typename
                ... on ProductVariant {
                  __typename
                  title
                  sku
                  id
                  quantityAvailable
                  availableForSale
                  product {
                    title
                    id
                  }
                  compareAtPrice {
                    amount
                    currencyCode
                  }
                  price {
                    amount
                    currencyCode
                  }
                  requiresShipping
                  image {
                    url
                  }
                  selectedOptions {
                    value
                    name
                  }
                  components(first: 10) {
                    edges {
                      node {
                        quantity
                        productVariant {
                          compareAtPrice {
                            amount
                            currencyCode
                          }
                          product {
                            title
                            id
                          }
                          title
                          price {
                            amount
                            currencyCode
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
        cost {
          totalAmount {
            amount
            currencyCode
          }
          subtotalAmount {
            amount
          }
          checkoutChargeAmount {
            amount
          }
          totalAmountEstimated
          subtotalAmountEstimated
        }
      }
      userErrors {
        code
        message
      }
    }
  }
`;

Expected behavior

The types should be generated

Actual behavior

What actually happens?
Fails with errors :

`Generate to ./src/platform/shopifyv2/storefront-types/storefront.generated.ts

✔ Load GraphQL schemas
✔ Load GraphQL documents
✖ GraphQL Document Validation failed with 4 errors;
  Error 0: Cannot query field "delivery" on type "Cart".
  at /src/platform/shopifyv2/commons/mutations/create-cart.ts:23:11
  Error 1: Unknown type "CartDeliveryAddress". Did you mean "DeliveryAddress", "CartDeliveryGroup", "CartDeliveryOption", "CartDeliveryGroupEdge", or …
  at /shopifyv2/commons/mutations/create-cart.ts:26:23
  Error 2: Cannot query field "discountApplication" on type "CartCodeDiscountAllocation".
  at /shopifyv2/commons/mutations/create-cart.ts:44:8
  Error 3: Cannot query field "discountApplication" on type "CartCodeDiscountAllocation".
  at /shopifyv2/commons/mutations/create-cart.ts:98:11`

Steps to reproduce the problem

Debug logs

// Paste any relevant logs here
@lizkenyon lizkenyon self-assigned this Jan 17, 2025
@lizkenyon
Copy link
Contributor

Hi there 👋

I believe this was because of an underlying error with the API that returned the schema. This should now be resolved. Please create a new issue if you continue to have similar problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants