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): @id field uniqueness at interface level - fixes #8434 #7710

Merged
merged 29 commits into from
Apr 17, 2021
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b2b5025
added unique directory
JatinDev543 Apr 6, 2021
e61d295
aadded existence query
JatinDev543 Apr 7, 2021
bb31c4e
modify rewrite object to check xid across implementation of interface
JatinDev543 Apr 8, 2021
5f468ce
fix a panic,added mutation unit tests
JatinDev543 Apr 9, 2021
d6e8441
fix test
JatinDev543 Apr 9, 2021
9dd3c22
fix test and add more test case for add mutation
JatinDev543 Apr 9, 2021
8bc068c
add schema
JatinDev543 Apr 9, 2021
1f4cb04
Merge branch 'master' of https://github.com/dgraph-io/dgraph into jat…
JatinDev543 Apr 9, 2021
d8a8510
added e2e mutation test
JatinDev543 Apr 9, 2021
3c6c61a
clean test
JatinDev543 Apr 9, 2021
b437d2f
clean test
JatinDev543 Apr 9, 2021
15b4501
clean test
JatinDev543 Apr 9, 2021
0dd1ebb
fix spaces
JatinDev543 Apr 9, 2021
e00a0df
added interface auth test
JatinDev543 Apr 9, 2021
1d2eec5
added some more tests and schema
JatinDev543 Apr 10, 2021
4f0a7a6
fix schema test
JatinDev543 Apr 10, 2021
8dd224b
clean test
JatinDev543 Apr 10, 2021
6f04115
clean code
JatinDev543 Apr 10, 2021
2af9a35
clean code
JatinDev543 Apr 10, 2021
c2838e2
clean code
JatinDev543 Apr 10, 2021
16ae849
fix formatting and test
JatinDev543 Apr 10, 2021
8291064
fix formatting
JatinDev543 Apr 11, 2021
78f2938
fix test
JatinDev543 Apr 11, 2021
4a6a86c
addressed rajas comments
JatinDev543 Apr 14, 2021
5a94e2a
changed arg name from unique to interface
JatinDev543 Apr 15, 2021
fba56a4
addressed abhimanyu's comments
JatinDev543 Apr 17, 2021
ca8e34d
change variable names
JatinDev543 Apr 17, 2021
0a147ce
Merge branch 'master' of github.com:dgraph-io/dgraph into jatin/GRAPH…
JatinDev543 Apr 17, 2021
9613499
fixed schema test
JatinDev543 Apr 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change variable names
  • Loading branch information
JatinDev543 committed Apr 17, 2021
commit ca8e34d245fe0f40100536d0f1238a63ba4b8b48
18 changes: 9 additions & 9 deletions graphql/resolve/mutation_rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ func (v *VariableGenerator) Next(typ schema.Type, xidName, xidVal string, auth b
// ABC.ab.cd and ABC.abc.d
// It also ensures that xids from different types gets different variable names
// here we are using the assertion that field name or type name can't have "." in them
typOriginated, _ := typ.FieldOriginatedFrom(xidName)
key = typOriginated.Name() + "." + flagAndXidName + "." + xidVal
xidType, _ := typ.FieldOriginatedFrom(xidName)
key = xidType.Name() + "." + flagAndXidName + "." + xidVal
}

if varName, ok := v.xidVarNameMap[key]; ok {
Expand Down Expand Up @@ -1406,7 +1406,7 @@ func rewriteObject(
// node added during the mutation rewriting. This is handled by adding the new blank UID
// to existenceQueryResult.

interfaceTypDef, interfaceVar := interfaceVariable(typ, varGen, xid.Name(), xidString)
interfaceTyp, interfaceVar := interfaceVariable(typ, varGen, xid.Name(), xidString)

// Get whether node with XID exists or not from existenceQueriesResults
_, interfaceUidExist := idExistence[interfaceVar]
Expand All @@ -1431,7 +1431,7 @@ func rewriteObject(
// if node is some other type as of xid Field then we can't upsert that
// and we returns error
retErrors = append(retErrors, xidErrorForInterfaceType(typ, xidString, xid,
interfaceTypDef.Name()))
interfaceTyp.Name()))
return nil, "", retErrors
}
} else {
Expand All @@ -1453,7 +1453,7 @@ func rewriteObject(
}

retErrors = append(retErrors, xidErrorForInterfaceType(typ, xidString, xid,
interfaceTypDef.Name()))
interfaceTyp.Name()))
return nil, upsertVar, retErrors

}
Expand All @@ -1465,7 +1465,7 @@ func rewriteObject(
mutationType == UpdateWithRemove), upsertVar, nil
}
retErrors = append(retErrors, xidErrorForInterfaceType(typ, xidString, xid,
interfaceTypDef.Name()))
interfaceTyp.Name()))
return nil, upsertVar, retErrors
}
} else {
Expand Down Expand Up @@ -1836,11 +1836,11 @@ func existenceQueries(
// Add one more existence query if given xid field is inherited from interface and has
// interface argument set. This is added to ensure that this xid is unique across all the
// implementation of the interface.
interfaceType, varInterface := interfaceVariable(typ, varGen,
interfaceTyp, varInterface := interfaceVariable(typ, varGen,
xid.Name(), xidString)
if interfaceType != nil {
if interfaceTyp != nil {
queryInterface := checkXIDExistsQuery(varInterface, xidString, xid.Name(),
typ, interfaceType)
typ, interfaceTyp)
ret = append(ret, queryInterface)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline in a call, we will have to handle case of duplicate XID for different implementing types using the variableObjMap or add a TODO

// Don't return just over here as there maybe more nodes in the children tree.
Expand Down