Open
Conversation
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?
Part of https://github.com/shop/issues-shopifyvm/issues/945
When a developer bumps
api_versionin a function'sshopify.extension.toml, the on-diskschema.graphqlbecomes stale. The nextshopify app function buildthen fails with crypticgraphql-code-generatorerrors like:…with no indication that the underlying problem is a stale schema that just needs to be re-fetched. Today the build path is fully local — it never consults
api_versionandschema.graphqlcarries no version metadata, so staleness is undetectable.The error surfaced gives them no actionable hint pointing at
shopify app function schema.WHAT is this pull request doing?
Stamps the
api_versionintoschema.graphqlwhenshopify app function schemawrites it, then validates that marker against the extension's TOML at the start of everyshopify app function build. When they disagree, the build aborts up-front with an actionable message instead of letting codegen fail mysteriously.New file
packages/app/src/cli/services/function/schema-version.ts— self-contained helpers:prependSchemaVersionHeader(definition, version)— adds a# api_version: <ver>marker line to the top of the SDL.readSchemaApiVersion(path)— scans the leading comment block for the marker; returnsundefinedfor missing files or legacy schemas (no marker).validateSchemaApiVersion({directory, localIdentifier, apiVersion})— throws anAbortErrorwith remediation when the on-disk marker disagrees with the configuredapi_version.Modified files
services/generate-schema.ts—shopify app function schemanow writes the marker as the first line of the SDL (both file and stdout output).services/build/extension.ts—buildFunctionExtensioninvokesvalidateSchemaApiVersiononce, up-front, before any function build work (typegen, esbuild, javy, wasm-opt, trampoline).Behavior
shopify app function schema).The schema header is a single line:
How to test your changes?
api_version = "2025-07"in the function'sshopify.extension.toml.schema.graphqlnow starts with# api_version: 2025-07.api_versionto"2025-10"in the TOML.shopify app function schema.schema.graphql(simulate an older fetched file). The build command should behave exactly as it did before this change (no false-positive abort).Post-release steps
N/A.
Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add