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

Handle (non-)nullability

Open chkimes opened this issue 10 years ago • 2 comments

At some point we'll need to support defining whether a field or argument is nullable or non-nullable. As for now, a decent starting point will just be forcing the nullability to match the CLR type's nullability. So nullable for classes, non-nullable for structs except Nullable<T>.

This isn't a long-term solution, since multiple ORMs support non-nullable relationships (e.g. Entity Framework with int SomethingId foreign keys). Also it would be nice to allow non-nullable arguments that map to a CLR class type.

chkimes avatar Apr 17 '16 22:04 chkimes

Support for changing nullability of a field will depend on #17.

chkimes avatar Apr 17 '16 22:04 chkimes

Per discussion with @rspeele:

Optionality of argument fields will be handled with an Optional<T> wrapper class (similar to Nullable<T> but allowing classes). This will indicate to the parser that a specified argument is not required. Arguments that are not wrapped with Optional are assumed to be required.

In the case of the initial query (see AddField in #17), if all required arguments are not supplied then validation fails. In the case of extra arguments (see WithArguments in #17), each successive filter will only be applied if all of the required arguments are present.

chkimes avatar Apr 22 '16 14:04 chkimes