graphql-dotnet / examples

Examples for GraphQL.NET

Home Page:https://graphql-dotnet.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there an example for how to perform a partial update on an existing record?

StingyJack opened this issue · comments

All i can find are Add/Insert in these examples.

These are basic examples. They are not intended to be exhaustive. It is quite possible that there is no such example.

Is what I'm asking for something that is possible to express via GraphQL?

You can write a mutation which accepts all field arguments as nullable (optional) and then only updates the fields in your database if the values are not null. You cannot determine if a field argument is null versus not specified, so this may not be helpful if you need to set null fields in your database. I’ve seen other people also define Boolean field arguments to indicate if the corresponding field should be updated. You’ll have to figure out the scenario that works best for your needs.

I've seen numerous discussions on this issue too (not set vs set with null).

@Shane32 I propose to close this one since repo provides basic examples.

You cannot determine if a field argument is null versus not specified

Regarding this... IIRC now we can. No?

Yes, and no, and yes. The arguments dictionary can be used to determine if an argument was supplied -- but it has to be noted that accessing the dictionary does not run the name through the name converter. But I would guess that this question more relates to an input object, in which case it isn't easily possible. But with ParseDictionary it is possible. I discussed a couple different implementations with ParseDictionary recently but I don't remember where.

I agree to close this here. If anything such a question should belong in the main repo.