graphql-net
graphql-net copied to clipboard
Argument deserialization
I'm playing with graphql-net and I really like it. One thing that I can't figure out is how args are deserialized. It seems that camelCase/pascalCase conversion is not working for args. Also, is it possible to get a plain JSON object (patch)?
patchUser(id: 1, patch: { displayName: "X" }) {
id,
displayName
}
A patch would be very useful as it includes information which fields should be updated. That's not available with strongly typed models.
Currently, args do not undergo any name transformation like properties do. There's not a particular reason for this, and I'm open to changing it.
We do support input objects (https://facebook.github.io/graphql/#sec-Input-Values), but we may not handle optional fields very well. Deserializing an input object with arbitrary fields (say to a Dictionary<string, object>
) is not currently supported, but also would not be terribly hard to do.
Do you have any plans for working on a feature like this? I'm not very familiar with the codebase yet, but I'll look into it and try to hack something on my own. Would you accept a PR if it works out?
I think adding deserialization to a Dictionary is a sensible thing to do. We've considered how to handle optional fields when deserializing to an object and it's a bit tricky, since I think we would need to introduce our own attributes and reflect over them (e.g. how to handle non-nullable reference types).
Also, I'm happy to accept any PRs that add features within the scope of the project.