Give each alias of a nested relation its own arguments and rows

Closed
FE
2d ago
+1366-260

Builds on #30473, which carries one relation-selection tree through the common query layer. This PR makes its keys GraphQL response keys, so a relation can be selected several times under aliases, each with its own arguments and rows (like SQL field AS alias). Scoped columns need the plain relation and a scoped one ("open action items, by due date, at most 1") in the same query. It has no knowledge of columns or views.

Changes

  • Selections keyed by response key: resolver selections are keyed by GraphQL response key. A selection's real field name, its arguments and, on merged selections, its response key live under the Symbol keys SELECTION_FIELD_NAME, SELECTION_ARGUMENTS and SELECTION_RESPONSE_KEY, so this bookkeeping cannot collide with the string keys clients control through aliases. getSelectionEntries lists each entry with its response key and field name.
  • Merging aliased selections: fields whose data is not per alias (composites, edges, node) go through mergeFieldSelections, which merges their aliased selections recursively by slot (field name plus response key). A response key reused under different aliases must request its field with the same arguments; otherwise the query fails with INVALID_QUERY_INPUT.
  • Response key rules: the selected-fields parser rejects a relation response key already used by a column (including a composite sub-column such as addressAddressCity), a join column, an aggregate or another relation of the object. Scalar aliases are unrestricted.
  • Records and formatting by response key: relationSelections keys are now response keys, each entry naming its source field next to its filter / orderBy / first, and records hold each relation under its response key. Aliased relations are masked, signed and counted like plain ones. The GraphQL connection helper and the direct-execution formatter return every field under its response key and read sub-fields, connection fields, __typename and group-by groupByDimensionValues by their real name. This fixes aliased nested fields coming back under the field name, and an aliased __typename inside a composite field crashing.
  • Group-by: aliased relations are attached to group-by records next to the formatted record, since formatResult only keeps field names.
  • Prototype safety: selection, result and field-name maps use null prototypes, so an alias such as constructor or __proto__ stays an ordinary key.
  • Unchanged: queries without aliases behave exactly as on #30473.

Stack

The work is split into short tracks that can be reviewed and merged in parallel. Each PR targets main or the one PR it builds on. Two PRs need several others; they target an integration branch (felix/relaxed-einstein-vxil3q-base-*, not a PR) that merges exactly their dependencies, so their diff shows only their own changes. A PR can merge once everything in its "Builds on" column is merged; retarget it to main at that point.

Size counts changed lines outside tests and generated files: S < 300, M 300–800, L > 800. Sizes are a snapshot and are not kept in sync with every push.

TrackPRWhat it doesSizeCodeTests / generatedBuilds on
Server: views#30339Per-column settings on view fields (label, record limit)S+300 −2+703 −152main
Server: views#30341A view can be owned by a one-to-many view field (scope view)M+584 −56+891 −4main
Server: views#30472Lookup: a view field shows one field of its related recordM+280 −38+428 −4#30339
Server: views#30466upsertViewFieldWithScope: save a column with its settings, lookup and scope in one migration (~600 lines moved out of view-widget-upsert)L+1330 −567+1117 −256#30339, #30341, #30472
Server: views#30450Expose column scopes and lookups in the view AI toolsS+31+222#30339, #30341, #30472
Server: query engine#30347Honor filter / orderBy / first on nested one-to-many relationsM+462 −86+509main
Server: query engine#30473One relation-selection tree through the common query layer (refactor, no behavior change)L+663 −685+277 −46#30347
Server: query engine#30465 👈Each alias of a nested relation gets its own arguments and rowsL+595 −237+727 −21#30473
Front#30468Query a relation under an alias with its own filter, sort and limitS+140 −19—main
Front#30469Don't recreate a saved sort that comes back under a new idS+21 −17+8main
Front#30348Extra table columns and the Edit column panel, behind IS_COLUMN_SETTINGS_ENABLEDM+718 −76+152 −30#30339
Front#30349Scope one-to-many columns from the Edit column panelL+1053 −92+316 −18#30348, #30466, #30468, #30469, #30465
Front#30439Lookup columns in the table, editable from their cells (absorbs #30440)L+805 −223+283 −30#30349
Front#30458Lookup and scoped columns on boards and calendarsM+404 −284+140 −7#30439

The longest dependency chain is #30339 → #30348 → #30349 → #30439 → #30458; everything else is one or two levels deep. #30339, #30341 and #30472 each add a 2.59 instance command, so whichever merges after another may need a fresh timestamp.

Testing

  • Integration nested-relation-query-arguments: two aliases with different arguments, inline and with variables, next to the plain relation; aliased sub-fields and connection fields; aliased relations in group-by records; an alias reusing a field name or a composite sub-column is rejected.
  • Integration message-visibility: masking applies through aliased relations.
  • Also run locally: group-by with records (+ RLS), nested per-parent limit (+ RLS), relation join RLS, soft-deleted relations, timeline, REST find-many and depth permissions.
  • Unit: selection collector, selection merging, direct-execution formatting, selected-fields parser, columns to select, max field count, record visibility collection, result getters.

Generated by Claude Code