I run into an issue with the Storefront types generation using codegen
codegen.yml:
overwrite: true
generates:
# Admin API Types
./generated/admin-graphql.tsx:
documents: "src/gql/admin/*.gql" # Path to your .graphql files (queries/mutations)
schema: "https://shopify.dev/admin-graphql-direct-proxy/2024-10" # or provide a URL if you're using a remote schema
plugins:
- "typescript"
- "typescript-operations"
# Storefront API Types
./generated/storefront-graphql.tsx:
documents: "src/gql/storefront/*.gql" # Path to your .graphql files (queries/mutations)
schema: "https://shopify.dev/storefront-graphql-direct-proxy/2024-10" # or provide a URL if you're using a remote schema
plugins:
- "typescript"
- "typescript-operations"
Running npx graphql-codegen --config codegen.yml
✔ Parse Configuration
⚠ Generate outputs
✔ Generate to ./generated/admin-graphql.tsx
❯ Generate to ./generated/storefront-graphql.tsx
✖
Failed to load schema from https://shopify.dev/storefront-graphql-direct-proxy/2024-10:
Could not obtain introspection result, received the following as response;
{ data: { directive: { fields: [Array] }, field: { fields: [Array] }, type: { fields: [Array] }, inputValue: { fields: [Array] } } }
GraphQLError: Could not obtain introspection result, received the following as response;
{ data: { directive: { fields: [Array] }, field: { fields: [Array] }, type: { fields: [Array] }, inputValue: { fields: [Array] } } }
at createGraphQLError (/Users/user/Documents/nextjs-proj/node_modules/@graphql-tools/utils/cjs/errors.js:31:12)
at getSchemaFromIntrospection (/Users/user/Documents/nextjs-proj/node_modules/@graphql-tools/wrap/cjs/introspect.js:20:42)
at /Users/user/Documents/nextjs-proj/node_modules/@graphql-tools/wrap/cjs/introspect.js:35:32
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async UrlLoader.load (/Users/user/Documents/nextjs-proj/node_modules/@graphql-tools/url-loader/cjs/index.js:220:29)
at async /Users/user/Documents/nextjs-proj/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:14:39
at async Promise.all (index 5)
at async loadFile (/Users/user/Documents/nextjs-proj/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:12:9)
at async /Users/user/Documents/nextjs-proj/node_modules/@graphql-tools/load/cjs/load-typedefs/collect-sources.js:191:25
GraphQL Code Generator supports:
- ES Modules and CommonJS exports (export as default or named export "schema")
- Introspection JSON File
- URL of GraphQL endpoint
- Multiple files with type definitions (glob expression)
- String in config file
Try to use one of above options and run codegen again.
◼ Load GraphQL documents
◼ Generate
Result: it generates admin schema but not storefront schema.