-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat: Mutation typed input #2167
feat: Mutation typed input #2167
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## develop #2167 +/- ##
===========================================
+ Coverage 74.14% 74.22% +0.07%
===========================================
Files 256 256
Lines 25399 25465 +66
===========================================
+ Hits 18831 18899 +68
+ Misses 5285 5277 -8
- Partials 1283 1289 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 14 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
// for collection create and update mutation operations. | ||
func (g *Generator) buildMutationInputTypes(collections []client.CollectionDefinition) error { | ||
for _, c := range collections { | ||
// Copy the loop variable before usage within the loop or it |
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.
thought: Note that this will no longer be needed starting with Go 1.22
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.
nitpick: Would appreciate a comment here mentioning 1.22
for regex search in the future, so can easily find some of these.
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.
As a side effect of this change the relationship alias has been replaced with the _id input field.
I don't understand what is meant by 'replaced' with the type_id
, because before we had both the 'type' alias and 'type_id'.
Why were the alias tests deleted? did we just drop support for aliases (i.e. a whole feature seems to have been dropped)?
IIRC this was a feature that was requested by one of the partners, and was implemented in:
- feat: Add alias to
groupBy
related object #1579 - feat: Allow relation alias on create and update #1609
More context:
https://discord.com/channels/427944769851752448/1061831110956421150/1113950104517365900
We talked about this briefly in the standup last week. Since the mutation input fields are now typed it is not possible to support relation field aliases (unless we add gql union types). |
It is possible if we set the mutation type for the foreign object as a |
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.
In order to not get this PR hung up by the reverting of the aliasing feature, lets keep the aliasing for now and lets try to reach consensus separately on what we want to do about the possibility of allowing embedded foreign objects.
Without the removal of aliasing, I think this PR can me approved and merged.
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.
LGTM! Awesome work! I love that we now have this implemented.
If you don't mind just adding the 1.22 reference as mentionned by Shahzad before merging.
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.
Sorry just reviewing, thanks for adding alias stuff back. I am mid review will appreciate if possible to wait for me to finish.
planner/create.go
Outdated
// Explain method returns a map containing all attributes of this node that | ||
// are to be explained, subscribes / opts-in this node to be an explainablePlanNode. | ||
func (n *createNode) Explain(explainType request.ExplainType) (map[string]any, error) { | ||
switch explainType { | ||
case request.SimpleExplain: | ||
return n.simpleExplain() | ||
return map[string]any{ | ||
dataLabel: n.input, |
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.
todo: the name dataLabel
doesn't make sense anymore. Please change to inputLabel
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.
Cheers for this PR! I like it a lot! Left some var renaming todos and in addition have this todo:
In planner/explain.go
file we have on line 56:
dataLabel = "data"
After renaming the variable please don't forget to change the value from"data"
to "input"
.
OR if you want to use request.Input
in all those instances and just remove the dataLabel
/inputLabel
, I am okay with that too :)
client/request/consts.go
Outdated
@@ -21,6 +21,7 @@ const ( | |||
|
|||
Cid = "cid" | |||
Data = "data" |
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.
todo: Please delete this Data
variable now, it is now not used anywhere.
planner/update.go
Outdated
return nil, err | ||
} | ||
simpleExplainMap[dataLabel] = data | ||
simpleExplainMap[dataLabel] = n.input |
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.
todo: Similar to other suggestions please change the variable name to be more relevant.
simpleExplainMap[dataLabel] = n.input | |
simpleExplainMap[inputLabel] = n.input |
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.
Cheers for doing all the todos!
## Relevant issue(s) Resolves sourcenetwork#2143 ## Description This PR adds a typed input object for create and update mutations. ~~As a side effect of this change the relationship alias has been replaced with the `<type>_id` input field.~~ Relational sub-documents cannot be created from mutation input in this implementation. Related SIP sourcenetwork/SIPs#10 ## Tasks - [x] I made sure the code is well commented, particularly hard-to-understand areas. - [x] I made sure the repository-held documentation is changed accordingly. - [x] I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in [tools/configs/chglog/config.yml](tools/configs/chglog/config.yml)). - [x] I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ... ## How has this been tested? Make test Specify the platform(s) on which this was tested: - MacOS
## Relevant issue(s) Resolves sourcenetwork#2143 ## Description This PR adds a typed input object for create and update mutations. ~~As a side effect of this change the relationship alias has been replaced with the `<type>_id` input field.~~ Relational sub-documents cannot be created from mutation input in this implementation. Related SIP sourcenetwork/SIPs#10 ## Tasks - [x] I made sure the code is well commented, particularly hard-to-understand areas. - [x] I made sure the repository-held documentation is changed accordingly. - [x] I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in [tools/configs/chglog/config.yml](tools/configs/chglog/config.yml)). - [x] I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ... ## How has this been tested? Make test Specify the platform(s) on which this was tested: - MacOS
Relevant issue(s)
Resolves #2143
Description
This PR adds a typed input object for create and update mutations.
As a side effect of this change the relationship alias has been replaced with the<type>_id
input field.Relational sub-documents cannot be created from mutation input in this implementation.
Related SIP https://github.com/sourcenetwork/SIPs/discussions/10
Tasks
How has this been tested?
Make test
Specify the platform(s) on which this was tested: