-
Notifications
You must be signed in to change notification settings - Fork 272
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
[JSONSelection] Remove rest: * { a b }
star selection syntax
#6185
Merged
Conversation
This file contains 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
✅ Docs Preview ReadyNo new or changed pages found. |
CI performance tests
|
lennyburdette
approved these changes
Oct 23, 2024
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.
thanks for doing this! i'm a fan of you deleting my code 😁
benjamn
added a commit
that referenced
this pull request
Oct 23, 2024
PR #6185 removed support for the following syntax for preserving dynamic keys of dictionary objects while mapping their values: ```graphql booksByISBN: books { * { title author }} ``` As suggested in the description of PR #6185, this pattern can be replaced with a `->mapValues` method call: ```graphql booksByISBN: books->mapValues(@ { title author }) ``` This PR tentatively implements that `->mapValues` method, filing it in the `future::` namespace to indicate it hasn't been shipped yet.
benjamn
added a commit
that referenced
this pull request
Oct 23, 2024
PR #6185 removed support for the following syntax for preserving dynamic keys of dictionary objects while mapping their values: ```graphql booksByISBN: books { * { title author }} ``` As suggested in the description of PR #6185, this pattern can be replaced with a `->mapValues` method call: ```graphql booksByISBN: books->mapValues(@ { title author }) ``` This PR tentatively implements that `->mapValues` method, filing it away in the `future::` namespace to indicate it hasn't been shipped yet.
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.
This PR removes the under-documented JSONSelection
StarSelection
syntax.The
StarSelection
syntax provided a way to capture all unselected properties of an input object, which could then be given a name by providing an alias (e.g.rest: *
) or further sub-selected by appending aSubSelection
(e.g.rest: * { id }
to select just theid
s).Another use case for the
*
syntax was to make it easier to handle dynamic dictionaries in GraphQL, which does not provide a way to select dynamic object keys:Supposing
books
is a dictionary whose keys are ISBN strings and whose values are objects, this selection grabs thetitle
andauthor
properties from each of those objects while preserving the ISBN keys and dictionary structure.Unfortunately, this syntax has interacted poorly with other JSONSelection functionality, including features we want to build. In particular, capturing only unselected fields with the
*
selection makes its behavior sensitive to the removal of otherNamedSelection
fields, which violates guiding principle #3.Fortunately, we have new tools to address the use cases
StarSelection
syntax was originally designed to solve. In particular, we can use->
methods to inspect available data and perform arbitrary processing of JSON dictionaries:Given these alternatives, I'm confident we can remove the special
*
syntax without eliminating any use cases, though this is definitely a breaking change for developers who were previously using the*
syntax. Please comment below if this removal is disruptive to you.