You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the best schema pattern for updateStudent mutation?
Full update:
updateStudent(id:ID!, student:StudentInput!)
The input will have all keys in Student required to be required in StudentInput. This way the update param is the "final state" we want the object to be
Partial update:
Same mutation schema as previous one, but the input types are all optional to allow partial updates. However the resolver implementation will look really ugly:
type Mutation{
updateStudentName(id:ID!, name:String)
updateStudentAddress(id:ID!, address:String)
updateStudentNumber(id:ID!, number:String)
}
Partial updates + one mutation per field
type Mutation {
updateStudent(id:ID!): UpdateStudentMutation!
}
type UpdateAccountMutation{
name(name:String): Student
address(address:String): Student
studentNumber(studentNumber:String): Student
}
For 1 vs 2/3/4, it is the debate of "final state" or partial "fields to update"
For 2 vs 3/4, it is the debate of all updates in "one mutation node" or "multi mutation nodes". And is 3/4 too much hazard for clients to wright ql operations?
For 3 vs 4, it is the the debate of "every mutation in root" or "grouped mutation". Extra thoughts, if mutation nodes are running in serial, then does that only apply to the root mutation or all sub-nodes of root mutation?
4 also have advantage that I only need to ACL checks on the root level comparing to 3
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
For example I have data type like this:
What is the best schema pattern for updateStudent mutation?
The input will have all keys in
Student
required to be required inStudentInput
. This way the update param is the "final state" we want the object to beSame mutation schema as previous one, but the input types are all optional to allow partial updates. However the resolver implementation will look really ugly:
For 1 vs 2/3/4, it is the debate of "final state" or partial "fields to update"
For 2 vs 3/4, it is the debate of all updates in "one mutation node" or "multi mutation nodes". And is 3/4 too much hazard for clients to wright ql operations?
For 3 vs 4, it is the the debate of "every mutation in root" or "grouped mutation". Extra thoughts, if mutation nodes are running in serial, then does that only apply to the root mutation or all sub-nodes of root mutation?
4 also have advantage that I only need to ACL checks on the root level comparing to 3
Beta Was this translation helpful? Give feedback.
All reactions