-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
What happened?
When performing an update mutation in Dgraph GraphQL, if the mutation's set patch includes a field annotated with @id (for example, name: String! @id) and the value is unchanged (the same as the existing node), the mutation response is { "data": { "update<Type>": null } } with no errors array. Other fields in the patch are skipped and not updated. If the @id value is actually changed, or the @id field is omitted entirely, the mutation works as expected.
This bug can be reliably triggered with the following minimal schema and mutation sequence:
type Thing {
id: ID!
code: String! @id
note: String
}- Add a node:
mutation {
addThing(input: [{ code: "CODE1", note: "Initial note" }]) {
thing { id code note }
}
}- Update with unchanged @id (BUG):
mutation {
updateThing(input: { filter: { code: ["CODE1"] }, set: { code: "CODE1", note: "Updated note" } }) {
thing { id code note }
}
}Expected: The note field should be updated.
Actual: The mutation response is:
{ "data": { "updateThing": null } }- Update with changed @id (works):
mutation {
updateThing(input: { filter: { code: ["CODE1"] }, set: { code: "CODE2", note: "Changed code" } }) {
thing { id code note }
}
}The node is updated and the code changes to CODE2.
What did you expect to happen?
If the @id value is unchanged, the mutation should return a payload with numUids and update other fields normally. If no actual change is made, it should return numUids: 0 with the payload, not null. The current null response makes it hard to distinguish from authorization failure.
Reproduction steps
- Deploy the schema above.
- Add a node with a value for the @id field.
- Attempt to update only a non-@id field, including the unchanged @id in the patch.
- Observe the null response.
Impact
- Mutations that include an unchanged @id field fail silently (null response, no errors).
- Blocks batching updates when unchanged @id is present.
- Forces client logic to strip unchanged @id fields before sending update mutations.
Workaround
Only include the @id field in set when its value is genuinely changing. Filter out unchanged @id fields before sending update mutations.
Environment
- Dgraph version: v25.0.0
- GraphQL endpoint:
/graphql
Additional context
This is not an authorization issue. Mutations succeed if the @id field is omitted or genuinely changed, and other mutations with the same token work. Presence of unchanged @id alone triggers the bug.
Please investigate and advise on a fix.