Skip to content
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

Merged
merged 3 commits into from
May 22, 2024

Conversation

nicholascioli
Copy link
Contributor

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.

  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Tests added and passing3
    • Unit Tests
    • Integration Tests
    • Manual Tests

Exceptions

Note any exceptions here

Notes

Footnotes

  1. 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.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

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.
@nicholascioli nicholascioli merged commit 334a8a5 into connectors May 22, 2024
9 of 11 checks passed
@nicholascioli nicholascioli deleted the nc/connectors/CNN-109-add-path-to-node branch May 22, 2024 19:03
Copy link
Contributor

@sachindshinde sachindshinde left a 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 Values 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
Copy link
Contributor

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 Keys, 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 Keys).

So to support that initial vector of Keys, 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
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

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]
Copy link
Contributor

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).

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.

None yet

4 participants