Warn when schema.graphql api_version mismatches extension TOML#7098
Draft
davejcameron wants to merge 5 commits intomainfrom
Draft
Warn when schema.graphql api_version mismatches extension TOML#7098davejcameron wants to merge 5 commits intomainfrom
davejcameron wants to merge 5 commits intomainfrom
Conversation
Contributor
Coverage report
Test suite run success3932 tests passing in 1513 suites. Report generated by 🧪jest coverage report action from c185d02 |
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?
When a developer changes
api_versionin theirshopify.extension.toml, the localschema.graphqlbecomes stale. The build then fails with cryptic type errors from typegen, with no indication that the schema simply needs to be re-fetched. This is a common failure case when working with Shopify Functions.WHAT is this pull request doing?
Adds a lightweight check at the start of
buildFunctionExtensionthat reads the first 512 bytes ofschema.graphqllooking for the server-stamped@apiVersiondirective (e.g.schema @apiVersion(version: "2025-04") {). If present and it doesn't match the TOML'sapi_version, a warning is printed before the build runs:If the directive isn't present (legacy schema files, or server hasn't adopted stamping yet), the check is silently skipped — no false positives.
Depends on https://github.com/shop/world/pull/543227 for the server to stamp schemas with the
@apiVersiondirective.How to test your changes?
api_version: "2025-01"shopify app function schemato fetch the schema (requires server-side directive stamping to be live, or manually addschema @apiVersion(version: "2025-01") {to the top ofschema.graphql)api_versionto"2025-04"inshopify.extension.tomlshopify app function buildMeasuring impact
How do we know this change was effective? Please choose one:
Checklist