Repository navigation
Check JavaScript function prepare variables against the run query on deploy - #8829
Draft
saga-dasgupta wants to merge 3 commits into
Draft
saga-dasgupta wants to merge 3 commits into
saga-dasgupta wants to merge 3 commits into
Conversation
A prepare target returns the variables for its run target's input query, but nothing checks them until the function runs, and a misspelled key silently falls back to the variable's default. Pre-deploy validation now follows what each prepare export returns back to where it's built, past type annotations and casts, and compares it with the run query's variable definitions. Anything it can't follow is an error.
Annotations and casts are claims nothing checks against the value, so they're blanked out of the function's own source before type checking, leaving types to come from the values. That makes the checker's type trustworthy wherever a value can't be followed, so object literals go through the same type-based check as everything else. Values are still followed branch by branch, since TypeScript widens literals like enum values and merges branches that differ only in them.
Contributor
Author
|
/snapit |
Contributor
|
🫰✨ Thanks @saga-dasgupta! Your snapshot has been published to npm. Built from Test the snapshot by installing your package globally: pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20261008004212Caution After installing, validate the version by running |
This branch has not been deployed
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?
A function's
preparetarget returnsvariablesfor itsruntarget's input query. For JavaScript functions, nothing checks these before the function runs:variablesisunknown;This PR catches those mistakes at deploy, and the developer can't skip the check.
WHAT is this pull request doing?
The check handles each
.preparetarget that has an export:.runtarget's input query and builds its variable definitions against the function'sschema.graphql.??/||and re-exports.nullorundefinedwhere the variable can't take them.Where it runs. The check is called from the function spec's
preDeployValidation, for JavaScript functions only. That runs before the upload on every deploy.Example output:
How to manually test your changes?
.prepareand.runtargets, misspell a key undervariablesin what the prepare export returns.shopify app deployfrom a/snapitbuild. It stops at "Running validation", names the file, line and key, and doesn't create a version.Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add