-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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(GraphQL): This PR allows @id field in interface to be unique across all implementing types #8876
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
harshil-goel
requested review from
akon-dey,
MichelDiz and
matthewmcneely
as code owners
June 14, 2023 21:38
dgraph-bot
added
area/core
internal mechanisms
area/graphql
Issues related to GraphQL support on Dgraph.
area/testing
Testing related issues
go
Pull requests that update Go code
labels
Jun 14, 2023
mangalaman93
requested changes
Jul 5, 2023
harshil-goel
force-pushed
the
harshil-goel/id-interface
branch
from
July 6, 2023 09:51
16979de
to
0c62b01
Compare
harshil-goel
requested review from
meghalims,
sanjayk-github-dev,
all-seeing-code,
billprovince and
joshua-goldstein
as code owners
July 6, 2023 09:51
harshil-goel
changed the title
Feat(GraphQL): This PR allows @id field in interface to be unique acr…
Feat(GraphQL): This PR allows @id field in interface to be unique across all implementing types
Jul 6, 2023
harshil-goel
force-pushed
the
harshil-goel/id-interface
branch
2 times, most recently
from
July 6, 2023 09:58
ed302d5
to
8b46cbb
Compare
…oss all the implementing types. (#7710) Currently, @id fields in the interface are unique only in one implementing type. But there are several use cases that require @id field to be unique across all the implementation types. Also currently. get a query on the interface can result in unexpected errors as we can have multiple implementing types have the same value for that @id field. Now we are allowing the @id field in the interface to be unique across all the implementing types. In order to do this, we have added a new argument interface of boolean type in the @id field. Whenever a @id field in interface type has an interface argument set then its value will be unique across all the implementing types. Users will get errors if they try to add a node with such a field and there is already a node with the same value of that field even in some other implementing types. This is true for other scenarios like adding nested value or while using upserts. If the interface argument is not present or its value is false then that field will be unique only for one implementing type. But such fields won't be allowed in argument to get query on interface in the future, see this PR also #7602 Example Schema, interface LibraryItem { refID: String! @id // This field is unique only for one implementing type itemID: String! @id(interface:true) // This field will be unique over all the implementing types inheriting this interface } type Book implements LibraryItem { title: String author: String } Related discuss Post: https://discuss.dgraph.io/t/uniqueness-for-id-fields-on-interface/13294
harshil-goel
force-pushed
the
harshil-goel/id-interface
branch
from
July 6, 2023 10:00
8b46cbb
to
b2d7e50
Compare
mangalaman93
requested changes
Jul 10, 2023
mangalaman93
approved these changes
Jul 13, 2023
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.
Please don't forget to file JIRA ticket for the pending work. LGTM
Unclear |
all-seeing-code
approved these changes
Jul 17, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/core
internal mechanisms
area/graphql
Issues related to GraphQL support on Dgraph.
area/testing
Testing related issues
go
Pull requests that update Go code
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.
Currently, @id fields in the interface are unique only in one implementing type. But there are several use cases that require @id field to be unique across all the implementation types. Also currently. get a query on the interface can result in unexpected errors as we can have multiple implementing types have the same value for that @id field.
Now we are allowing the @id field in the interface to be unique across all the implementing types. In order to do this, we have added a new argument interface of boolean type in the @id field.
Whenever a @id field in interface type has an interface argument set then its value will be unique across all the implementing types. Users will get errors if they try to add a node with such a field and there is already a node with the same value of that field even in some other implementing types. This is true for other scenarios like adding nested value or while using upserts.
If the interface argument is not present or its value is false then that field will be unique only for one implementing type. But such fields won't be allowed in argument to get query on interface in the future, see this PR also #7602
Example Schema,
interface LibraryItem {
refID: String! @id // This field is unique only for one implementing type
itemID: String! @id(interface:true) // This field will be unique over all the implementing types inheriting this interface
}
type Book implements LibraryItem {
title: String
author: String
}
Related discuss Post: https://discuss.dgraph.io/t/uniqueness-for-id-fields-on-interface/13294
Cherry picked from: #7710