graphql-net icon indicating copy to clipboard operation
graphql-net copied to clipboard

Argument deserialization

Open mstijak opened this issue 8 years ago • 3 comments

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.

mstijak avatar Oct 19 '16 14:10 mstijak

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.

chkimes avatar Oct 20 '16 13:10 chkimes

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?

mstijak avatar Oct 20 '16 13:10 mstijak

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.

chkimes avatar Oct 21 '16 13:10 chkimes