fix(api-codegen-preset): generate string instead of any for custom scalars#3099
Open
byrichardpowell wants to merge 1 commit intomainfrom
Open
fix(api-codegen-preset): generate string instead of any for custom scalars#3099byrichardpowell wants to merge 1 commit intomainfrom
byrichardpowell wants to merge 1 commit intomainfrom
Conversation
…alars Shopify API custom scalars (DateTime, Money, URL, HTML, etc.) now resolve to `string` in generated TypeScript output rather than `any`. The JSON scalar resolves to `unknown`. Uses the typescript codegen plugin's `defaultScalarType` and `scalars` options, so any future scalars added to the Shopify API are handled automatically without code changes. Fixes #1154 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WHY are these changes introduced?
Fixes #1154
When using
shopifyApiProject()orshopifyApiTypes(), all Shopify-specific custom scalars (DateTime,Money,URL,HTML,FormattedString,Decimal,UnsignedInt64, etc.) were typed asanyin the generated output. This is because the@graphql-codegen/typescriptplugin defaults unknown scalars toanywhen noscalarsconfig is provided, and the preset never configured one.WHAT is this pull request doing?
Adds two config keys to the
typescriptcodegen plugin invocation inshopifyApiTypes():defaultScalarType: 'string'— all custom scalars (current and future) now generate asstring, which is the correct runtime type for virtually all Shopify API scalars (DateTime,Money,URL,HTML, etc.)scalars: {JSON: 'unknown'}— overrides the one exception; theJSONscalar generates asunknownrather thanstringBecause
defaultScalarTypeis used rather than a hardcoded list, any new scalars Shopify adds to the API in future versions are handled automatically without code changes.Type of change
Checklist
pnpm changesetto create a draft changelog entry (do NOT update theCHANGELOG.mdfiles manually)