Shopify / shopify-app-js

MIT License
297 stars 116 forks source link

Error 0: Unknown type "BuyerInput". Did you mean "MoneyInput" or "CartInput"? #983

Open dimaportenko opened 5 months ago

dimaportenko commented 5 months ago

Issue summary

I'm trying to generate types for the following query

export const getProductsTestQuery = `#graphql
query RecommendedProducts($buyer: BuyerInput) @inContext(buyer: $buyer) {
  products(first: 10) {
    nodes {
      id
      priceRange {
        maxVariantPrice {
          amount
          currencyCode
        }
        minVariantPrice {
          amount
          currencyCode
        }
      }
    }
  }
}`

but I'm getting the following error

Error 0: Unknown type "BuyerInput". Did you mean "MoneyInput" or "CartInput"?

my .graphqlrc.ts

import { ApiType, shopifyApiProject } from '@shopify/api-codegen-preset'

const storefrontApiVersion = '2024-04'

export default {
  schema: [
    `https://shopify.dev/storefront-graphql-direct-proxy/${storefrontApiVersion}`,
  ],
  projects: {
    default: shopifyApiProject({
      apiType: ApiType.Storefront,
      apiVersion: storefrontApiVersion,
      documents: ['./src/services/**/*.storefront.{js,ts,jsx,tsx}'],
      outputDir: './types',
    }),
  },
}

Expected behavior

Types are generated.

Actual behavior

  ❯ Generate to ./types/storefront.types.d.ts
    ✔ Load GraphQL schemas
    ✔ Load GraphQL documents
    ✖ GraphQL Document Validation failed with 2 errors;
      Error 0: Unknown type "BuyerInput". Did you mean "MoneyInput" or "CartInput"?
      at src/services/ShopifyProductService/queries.storefront.ts:2:35
      Error 1: Unknown argument "buyer" on directive "@inContext".
      at src/services/ShopifyProductService/queries.storefront.ts:2:58
  ❯ Generate to ./types/storefront.generated.d.ts
    ✔ Load GraphQL schemas
    ✔ Load GraphQL documents
    ✖ GraphQL Document Validation failed with 2 errors;
      Error 0: Unknown type "BuyerInput". Did you mean "MoneyInput" or "CartInput"?
      at src/services/ShopifyProductService/queries.storefront.ts:2:35
      Error 1: Unknown argument "buyer" on directive "@inContext".
      at src/services/ShopifyProductService/queries.storefront.ts:2:58

Please let me know if any more details are required. I love the type generation feature but this issue will not allow me to use it.

matteodepalo commented 5 months ago

Hi @dimaportenko thank you for opening this issue. Any reason why the schema value is an array instead of just being the string pointing to the schema?

dimaportenko commented 5 months ago

hi @matteodepalo, I found this one as config sample https://github.com/Blazity/enterprise-commerce/blob/main/.graphqlrc.ts, I'm going to add admin api later as well. I also tried scheme which I found on the github and it was working fine, like this one https://github.com/luisfalconmx/klot-ecommerce/blob/2d5afee9a73e7d1338cad72a21652646524d4310/src/generated/storefront.schema.ts#L503.

matteodepalo commented 5 months ago

Hi @dimaportenko thank you for providing a schema reference, I'll put this issue into our backlog so that we can take a better look.

dimaportenko commented 5 months ago

@matteodepalo thank you. For me, it looks like BuyerInput isn't in my schema. So either

github-actions[bot] commented 4 months ago

We are closing this issue because we did not hear back regarding additional details we needed to resolve this issue. If the issue persists and you are able to provide the missing clarification we need, feel free to respond and reopen this issue.

We appreciate your understanding as we try to manage our number of open issues.

github-actions[bot] commented 4 months ago

We are closing this issue because we did not hear back regarding additional details we needed to resolve this issue. If the issue persists and you are able to provide the missing clarification we need, feel free to respond and reopen this issue.

We appreciate your understanding as we try to manage our number of open issues.

github-actions[bot] commented 2 months ago

We're labeling this issue as stale because there hasn't been any activity on it for 60 days. While the issue will stay open and we hope to resolve it, this helps us prioritize community requests.

You can add a comment to remove the label if it's still relevant, and we can re-evaluate it.

github-actions[bot] commented 2 days ago

We're labeling this issue as stale because there hasn't been any activity on it for 60 days. While the issue will stay open and we hope to resolve it, this helps us prioritize community requests.

You can add a comment to remove the label if it's still relevant, and we can re-evaluate it.