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

Feat(GraphQL): This PR allows @id field in interface to be unique across all implementing types #8876

Merged
merged 2 commits into from
Jul 17, 2023

Commits on Jul 6, 2023

  1. Feat(GraphQL): This PR allows @id field in interface to be unique acr…

    …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 committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    b2d7e50 View commit details
    Browse the repository at this point in the history

Commits on Jul 13, 2023

  1. Updated comments

    Harshil Goel committed Jul 13, 2023
    Configuration menu
    Copy the full SHA
    310a9fa View commit details
    Browse the repository at this point in the history