Skip to content

Commit

Permalink
Feat(GraphQL): This PR allow multiple @id fields in a type. (#7235)
Browse files Browse the repository at this point in the history
Fixes GRAPHQL-924
Currently, we only allow single xid or external id fields in a type with the @id directive.
Now, we are extending this to have multiple external @id fields in a type. Every such field will be unique over all the nodes of that type. As of now, fields with @id directive will be immutable. get query will work for all the fields with the @id type.
RFC:https://discuss.dgraph.io/t/wip-rfc-allow-multiple-unique-fields-in-graphql-schema/12008
Co-authored-by: Rajas Vanjape <rajas@dgraph.io>
  • Loading branch information
JatinDev543 authored Feb 22, 2021
1 parent 496cfeb commit 91e3366
Show file tree
Hide file tree
Showing 22 changed files with 2,049 additions and 357 deletions.
2 changes: 1 addition & 1 deletion ee/acl/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func TestCreateAndDeleteUsers(t *testing.T) {
resp := createUser(t, token, userid, userpassword)
require.Equal(t, 1, len(resp.Errors))
require.Equal(t, "couldn't rewrite mutation addUser because failed to rewrite mutation payload because id"+
" alice already exists for type User", resp.Errors[0].Message)
" alice already exists for field name inside type User", resp.Errors[0].Message)
checkUserCount(t, resp.Data, 0)

// delete the user
Expand Down
2 changes: 1 addition & 1 deletion graphql/e2e/auth/add_mutation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ func TestUpsertMutationsWithRBAC(t *testing.T) {
require.Error(t, gqlResponse.Errors)
require.Equal(t, len(gqlResponse.Errors), 1)
require.Contains(t, gqlResponse.Errors[0].Error(),
"GraphQL debug: id already exists for type Tweets")
"GraphQL debug: id tweet1 already exists for field id inside type Tweets")
} else {
common.RequireNoGQLErrors(t, gqlResponse)
require.JSONEq(t, tcase.result, string(gqlResponse.Data))
Expand Down
2 changes: 1 addition & 1 deletion graphql/e2e/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func TestAddMutationWithXid(t *testing.T) {
require.Error(t, gqlResponse.Errors)
require.Equal(t, len(gqlResponse.Errors), 1)
require.Contains(t, gqlResponse.Errors[0].Error(),
"GraphQL debug: id already exists for type Tweets")
"GraphQL debug: id tweet1 already exists for field id inside type Tweets")

// Clear the tweet.
tweet.DeleteByID(t, user, metaInfo)
Expand Down
1 change: 1 addition & 0 deletions graphql/e2e/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,7 @@ func RunAll(t *testing.T) {
t.Run("cyclically linked mutation", cyclicMutation)
t.Run("parallel mutations", parallelMutations)
t.Run("input coercion to list", inputCoerciontoList)
t.Run("multiple external Id's tests", multipleXidsTests)
t.Run("Upsert Mutation Tests", upsertMutationTests)

// error tests
Expand Down
Loading

0 comments on commit 91e3366

Please sign in to comment.