-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
connect: add path to node #5206
connect: add path to node #5206
Conversation
This commit adds support for adding a path to a connect node, allowing for JSON selections to be built as the query planner traverses the connect-specific graph.
apollo-federation/src/sources/connect/fetch_dependency_graph/mod.rs
Outdated
Show resolved
Hide resolved
apollo-federation/src/sources/connect/fetch_dependency_graph/mod.rs
Outdated
Show resolved
Hide resolved
apollo-federation/src/sources/connect/fetch_dependency_graph/mod.rs
Outdated
Show resolved
Hide resolved
apollo-federation/src/sources/connect/fetch_dependency_graph/mod.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed the logic for add_path()
here, looks fine to me!
(One thing I've mentioned in DMs is that the way we compare Value
s currently cares about the order of fields in object values when we don't want it to, but this will be fixed across the codebase in a later PR.)
Selections { | ||
/// Property path from the head |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The gist here is that the JSON selection grammar starts with
JSONSelection ::= NakedSubSelection | PathSelection
NakedSubSelection ::= NamedSelection* StarSelection?
In the case where JSONSelection
is a PathSelection
, note that PathSelection
is really just a non-empty vector of Key
s, potentially followed by a SubSelection
. In the case where JSONSelection
is a NakedSubSelection
, it's really just a SubSelection
without braces (which may be empty, and can be thought of as a PathSelection
with an empty vector of Key
s).
So to support that initial vector of Key
s, we have head_property_path
. (I think part of the confusion may come from calling it a "path"; maybe just calling it head_keys
is better?)
tail_selection: Option<(Name, PathTailSelection)>, | ||
}, | ||
|
||
/// The full selection from a (potentially) different root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This selection starts at the "root", similarly to PathSelections::Selections
. (Or rather, when I'm saying "root", I mean the root of the JSON data returned by the API call; I'm not sure what "different root" means here.)
selection: JSONSelection, | ||
}, | ||
} | ||
|
||
/// A path to a specific selection, not from the root. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't necessarily say this a path to a specific selection (this is more like the final selection of a path, though you mention that below).
#[derive(Debug, Clone)] | ||
pub(crate) enum PathTailSelection { | ||
/// Simple selection using a chain of keys. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify a bit, this represents the case where a selection returns a value that represents a GraphQL enum value or built-in scalar, in which case the data represents a NamedSelection
without any trailing SubSelection
.
Selection { | ||
/// The chain of [Key]s to traverse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mentioned it above, but I'm wondering whether it'd be less confusing to call this e.g. keys
instead of property_path
to avoid referencing the word "path".
path_selection: PathSelection, | ||
}, | ||
|
||
/// Custom selection using a [PathSelection] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if "custom selection" is the right phrase here, it's more of a selection that returns a GraphQL custom scalar (similarly below).
This commit adds support for adding a path to a connect allowing for JSON selections to be built as the query traverses the connect-specific graph.
Checklist
Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.
Exceptions
Note any exceptions here
Notes
Footnotes
It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this. ↩
Configuration is an important part of many changes. Where applicable please try to document configuration examples. ↩
Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions. ↩