Skip to content

Fix Shopify Function GraphQL scalar types - #8250

Merged
davejcameron merged 1 commit into
mainfrom
cx-fix-cart-subtotal-decimal
Aug 4, 2026
Merged

Fix Shopify Function GraphQL scalar types#8250
davejcameron merged 1 commit into
mainfrom
cx-fix-cart-subtotal-decimal

Conversation

@davejcameron

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Shopify Function type generation leaves custom GraphQL scalars as any, which removes useful type safety from generated JavaScript and TypeScript APIs.

WHAT is this pull request doing?

Adds default TypeScript mappings for every custom scalar currently used by Shopify Function schemas. Unknown future scalars fall back to unknown instead of any, while mappings configured by the app developer continue to take precedence.

The generated codegen configuration is temporary and does not modify the function project.

How to test your changes?

  • pnpm --filter @shopify/app vitest run src/cli/services/function/build.test.ts
  • pnpm --filter @shopify/app type-check
  • pnpm --filter @shopify/app lint -- --no-cache

Checklist

  • I have considered possible cross-platform impacts (Mac, Linux, Windows)
  • I have considered possible documentation changes
  • I have considered analytics changes to measure impact
  • The change is user-facing and includes a patch changeset

Copilot AI lite review requested due to automatic review settings August 4, 2026 14:08
@davejcameron
davejcameron requested a review from a team as a code owner August 4, 2026 14:08
@github-actions github-actions Bot added the Area: @shopify/app @shopify/app package issues label Aug 4, 2026
@davejcameron
davejcameron force-pushed the cx-fix-cart-subtotal-decimal branch from 6ed9789 to 49966c5 Compare August 4, 2026 14:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves Shopify Function GraphQL type generation by replacing any-typed custom scalar outputs with safer default TypeScript scalar mappings. It does this by generating a temporary codegen config that injects Shopify scalar defaults (and uses unknown as the fallback), while still allowing user-defined mappings to override defaults.

Changes:

  • Add default TypeScript mappings for known Shopify Function GraphQL custom scalars, with defaultScalarType set to unknown.
  • When a codegen config exists in the function’s package.json, generate a temporary merged codegen config file and run graphql-code-generator against it.
  • Update unit tests and add a patch changeset for the user-facing typegen behavior change.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/app/src/cli/services/function/build.ts Reads codegen from package.json, merges in default scalar mappings, and runs codegen using a temporary config file.
packages/app/src/cli/services/function/build.test.ts Updates mocks/assertions and adds coverage for scalar defaulting and user override behavior.
.changeset/curvy-carrots-typegen.md Adds a patch changeset noting improved scalar type generation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/app/src/cli/services/function/build.ts Outdated
@davejcameron
davejcameron force-pushed the cx-fix-cart-subtotal-decimal branch from 49966c5 to 6df87eb Compare August 4, 2026 14:18
Assisted-By: devx/e85a0d53-5619-4bb5-a163-93bbf6a5c02e
@davejcameron
davejcameron force-pushed the cx-fix-cart-subtotal-decimal branch from 6df87eb to ff7745e Compare August 4, 2026 14:48
@davejcameron
davejcameron added this pull request to the merge queue Aug 4, 2026
Merged via the queue into main with commit 83ca0ea Aug 4, 2026
52 of 53 checks passed
@davejcameron
davejcameron deleted the cx-fix-cart-subtotal-decimal branch August 4, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: @shopify/app @shopify/app package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants