You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The codgen typescript plugin has an option to generate "as const" enums, which are nice in that they don't need to be imported. So e.g. you can pass "PRODUCT" as a MetafieldOwnerType without having to import a run-time enum (but you still get type checking in modern Typescript). It would be nice if shopifyApiProject and shopifyApiTypes would support this as an option. I think this is a pretty easy change -- happy to submit a PR if it's helpful.
Right now I have to roll my own config using the preset and replicate much of what is in those function:
import{ApiType,pluckConfig,preset}from"@shopify/api-codegen-preset";importfsfrom"fs";constschemaFile="./src/shopify/types/admin-2025-01.schema.json";constschema="https://shopify.dev/admin-graphql-direct-proxy/2025-01";constschemaFileExists=fs.existsSync(schemaFile);exportdefault{// For syntax highlighting / auto-complete when writing operations
schema,documents: ["./src/**/*.{js,ts,jsx,tsx}","!dist","!node_modules/"],projects: {default: {// For type extraction
schema,documents: ["./src/**/*.{js,ts,jsx,tsx}","!dist","!node_modules"],extensions: {codegen: {// Enables support for `#graphql` tags, as well as `/* GraphQL */`
pluckConfig,generates: {
...(schemaFileExists
? {}
: {[schemaFile]: {
schema,plugins: ["introspection"],config: {minify: true},},}),"./src/shopify/types/admin.types.d.ts": {plugins: ["typescript"],config: {enumsAsConst: true,},},"./src/shopify/types/admin.generated.d.ts": {
preset,presetConfig: {apiType: ApiType.Admin,},},},},},},},};
The text was updated successfully, but these errors were encountered:
Overview/summary
The codgen typescript plugin has an option to generate "as const" enums, which are nice in that they don't need to be imported. So e.g. you can pass "PRODUCT" as a
MetafieldOwnerType
without having to import a run-time enum (but you still get type checking in modern Typescript). It would be nice ifshopifyApiProject
andshopifyApiTypes
would support this as an option. I think this is a pretty easy change -- happy to submit a PR if it's helpful.Right now I have to roll my own config using the preset and replicate much of what is in those function:
The text was updated successfully, but these errors were encountered: