-
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
fix(GRAPHQL): fix duplicate xid error for multiple xid fields. #7546
Conversation
graphql/resolve/mutation_rewriter.go
Outdated
// } | ||
// } | ||
// } | ||
// The two generated kes for this case will be |
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.
nit: keys
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.
fixed.
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.
Nicely written tests covering a wide range of cases.
We were getting duplicate xid error for the multiple xid fields if typeName+xidName+xidValue is same for those fields. The reason for this is that we need to generate unique query variables for the xids field while doing mutation rewriting and for that we use a map to variable names. we were using below key for that map key = typ.FieldOriginatedFrom(xidName) + xidName + xidVal This was generating same key for different xid fields. For example in below type we have two fields with id fields type ABC { ab: String! @id abc: String! @id } And below mutation try to set them such that key = typ.FieldOriginatedFrom(xidName) + xidName + xidVal will be same for both of them i.e. ABC+ab+cd=ABC+abc+d=ABCabcd mutation { addABC(input: [{ ab: "cd", abc: "d" }]) { aBC { ab abc } } } This error also occur in multiple types. We now added "." between values to separate typename and xidname , and the xidValue.This will ensure unique keys for xid fields across types. key = typ.FieldOriginatedFrom(xidName) + "." + xidName + "." + xidVal
We were getting duplicate xid error for the multiple xid fields if
typeName+xidName+xidValue
is same for those fields. The reason for this is that we need to generate unique query variables for the xids field while doing mutation rewriting and for that we use a map to variable names.we were using below key for that map
key = typ.FieldOriginatedFrom(xidName) + xidName + xidVal
This was generating same key for different xid fields. For example in below type we have two fields with id fields
And below mutation try to set them such that
key = typ.FieldOriginatedFrom(xidName) + xidName + xidVal
will be same for both of them i.e.ABC+ab+cd=ABC+abc+d=ABCabcd
This error also occur in multiple types.
We now added "." between values to separate typename and xidname , and the xidValue.This will ensure unique keys for xid fields across types.
key = typ.FieldOriginatedFrom(xidName) + "." + xidName + "." + xidVal
This change is