Support target-level input query variables on functions - #8471
Draft
saga-dasgupta wants to merge 1 commit into
Draft
Support target-level input query variables on functions#8471saga-dasgupta wants to merge 1 commit into
saga-dasgupta wants to merge 1 commit into
Conversation
Input queries have always been per-target (`input_query` on each `[[targeting]]` entry) while their variables were per-function (`[input.variables]`). shop/world PR 1015868 closes that asymmetry in Core by adding `input_query_variables` to `Execution::FunctionTarget`; this is the CLI half. - Accepts `input_variables` on a `[[targeting]]` entry and forwards it to the deploy payload as `input_query_variables.single_json_metafield`, the same shape already used at the extension level. - Rejects mixing extension-level `[input.variables]` with target-level `input_variables`, reported per offending target so the error points at the same line Core's deploy-time validator would. Co-Authored-By: Claude Opus 5 (1M context) <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?
Function input queries have always been per-target — each
[[targeting]]entry gets its owninput_query. Their variables, however, were per-function: a single extension-level[input.variables]applied to every target.shop/world#1015868 closes that asymmetry in Core by adding
input_query_variablestoExecution::FunctionTarget. That PR's own description lists three CLI follow-ups; this is all three.WHAT is this pull request doing?
In
function.ts:Accepts
input_variableson a[[targeting]]entry. Same{namespace, key}shape as the extension-level field, now extracted into a sharedInputVariablesSchemaso the two can't drift.Forwards it to the deploy payload as
input_query_variables: {single_json_metafield: ...}on each target — identical wrapping to the extension-level field, matchingFunctions::SingleJsonMetafieldInputQueryVariables.Rejects mixing the two levels via
superRefine. An issue is added per offending target at['targeting', <index>, 'input_variables'], so the error points at the same line Core's deploy-time validator would, rather than at the top of the TOML.The
config.targeting.mapcallback parameter is renamedconfig→targeting; it shadowed the outerconfig, which made the newtargeting.input_variablesline read as though it were reaching for extension-level configuration.FunctionExtensionSchemais now exported so the tests cansafeParseconfigurations directly rather than reaching through the spec object (schemais onCreateExtensionSpecType, not on the returnedExtensionSpecification). This follows theUIExtensionSchemaprecedent inui_extension.ts. Knip is happy with it, but it is a genuine visibility change worth a reviewer's eye.This must not reach a CLI release before shop/world#1015868 merges and deploys. Until then the Core property does not exist, and a deployed CLI sending
input_query_variablesontargets[]writes a field the platform drops. Happy to drop the changeset and re-add it at merge time if that's the safer sequencing — say the word.Out of scope
prepare-target rules. Deliberately excluded, mirroring the Core PR: that target does not exist in the codebase yet, so CLI validation would have no server counterpart and would be validating a handle Core rejects as unknown.input_variablesbut lacks them. Core'sper_target_variablesmode is all-or-nothing:targets.any?(&:input_query_variables)switches every target to the per-target validator. So addinginput_variablesto target 0 can make target 1 fail deploy with "Variable definitions are missing" if target 1's query declares GraphQL variables. Catching that locally requires parsing each target's.graphqlfor variable declarations — worth its own change.How to test your changes?
New coverage: the deploy-payload mapping, plus a
describe('input variables placement')block covering rejection with the exact message and path, multiple offending targets (asserting non-offending siblings are left alone), target-level-only, and extension-level-only.Measuring impact
Checklist
🤖 Generated with Claude Code