I am currently learning graphql and I am not sure if I correctly understand how mutations are supposed to work, especially when combined with subscriptions.
I have a page with client details, that include a description and a list of software products he has purchased from our company. In the interface there is one edit button for the description, a plus button to add a new software product to the client's list and minus buttons for each product to enable removing them.
I currently added a mutation that takes the id of the client and a string (newDescription) as parameters and updates the client's description. Is that right or should I have the id and a ClientInputType (containing a field description) and pass those as parameters? More importantly, if I use the ClientInputType and it contains both the description and the list of software products, is there a way I can update only one field at a time (in order to update the client using the same mutation, but change only the required fields depending on which button was pressed in the interface)?
public Mutation(IClientRepository clientRepository)
{
this.FieldAsync<ClientType>(
"updateClient",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<IntGraphType>> { Name = "id" },
new QueryArgument<StringGraphType> { Name = "newDescription" }
),
resolve: async ctx =>
{...}
}
In other words, can I let graphql know, in any way, that I want to update only one field in the ClientInputType and that it should ignore the others? What should a mutation return? I am curently returning the updated client.