Skip to content

Support dotted embedding paths in nested sourced_from relationship chains#1251

Merged
myronmarston merged 3 commits into
mainfrom
nested-sourced-from-dotted-embedding-paths
Jun 12, 2026
Merged

Support dotted embedding paths in nested sourced_from relationship chains#1251
myronmarston merged 3 commits into
mainfrom
nested-sourced-from-dotted-embedding-paths

Conversation

@ellisandrews-toast

Copy link
Copy Markdown
Collaborator

Why

The nested sourced_from feature is meant to work for any schema, but as merged it only handled embedding fields that sit directly on each relationship's parent type. Real schemas can nest the embedded type one or more object levels down — e.g. a list of Players reached via roster.players rather than a top-level players field. In that case, resolving the parent_relationship failed with a "field does not exist" error, so you simply couldn't source into a nested element unless it happened to be a direct field.

This closes that gap: an embedding field referenced via parent_field_name may now be a dotted path that descends through intermediate object fields. The embedding path is expanded into one navigation segment per component, so the sourced data can reach elements nested arbitrarily deep.

Scope / behavior notes

  • Intermediate lists are rejected (only the final embedding field may be a list), with an error that points at the supported alternative — model the intermediate list as its own parent_relationship link, so each list level is matched by its own foreign key. Multi-link chains already support arbitrary list nesting this way.
  • Naming convention: parent_field_name now resolves by the field's declared name, consistent with how sourced_from source paths and equivalent_field already resolve. Previously it incidentally required the internal name_in_index. Note "declared name" is not the same as "exposed in GraphQL" — indexing_only embedding fields are still resolvable, since they have a declared name even though they're hidden from the schema.

Testing

Unit coverage added for: object→list and object-leaf dotted paths, public-name resolution with a distinct name_in_index, the intermediate-list rejection, an unresolvable path, and a deeply nested chain that mixes object hops, multiple list links, and name_in_index renames.

- Deal with intermediate list fields while resolving the path instead of after-the fact.
- Map over the entire list of path parts instead of splitting the leaf part from the others.
- Separate building the `path_segments` from concatting them to the `path_segments` array.

@myronmarston myronmarston left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I pushed a commit with a recommended refactor. I also left some inline suggestions below which I'll apply shortly so we can get this merged. For the parent_field_name renaming I'll tackle that in a follow up PR.

Co-authored-by: Myron Marston <myron.marston@gmail.com>
@myronmarston myronmarston enabled auto-merge (squash) June 12, 2026 22:05
@myronmarston myronmarston disabled auto-merge June 12, 2026 22:06
@myronmarston myronmarston enabled auto-merge (squash) June 12, 2026 22:06
@myronmarston myronmarston merged commit d1445e9 into main Jun 12, 2026
25 checks passed
@myronmarston myronmarston deleted the nested-sourced-from-dotted-embedding-paths branch June 12, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants