ChilliCream / ChilliCream/graphql-platform
A helper method equivalent to the [GraphQLNonNullType] attribute for IObjectFieldDescriptor
@michaelstaib is already working on this.
Since Oct 19, 2020.
- Dominant language
- C#
- Stars
- 5.8k
- Forks
- 810
- Avg merge
- 15h 39m
- Merged PRs (30d)
- 98
Description
Currently in Hot Chocolate, unless you use C# 8.0 nullable reference types (which is not really a nice-to-use and pretty feature, and has its own limitations and problems), you would have to explicitly specify which properties/methods that have a reference type should be non-nullable.
You could currently do this using attributes like this:
[GraphQLNonNullType]
public string Title { get; set; }
But to achieve the same thing using IObjectFieldDescriptor's fluent API, this is what you would have to do:
descriptor.Field(p => p.Title).Type<NonNullType<StringType>>();
which is:
- Ugly and long
- The
StringTypepart is effectively unnecessary and redundant - Looking at that line of code, you're not sure whether the type itself is being changed or it's just being set to non-nullable.
I'm sure you would agree that having a nice little helper method like NonNull() would make the code above way cleaner, more readable, and more understandable at first sight.
descriptor.Field(p => p.Title).NonNull();
It also makes sense to have such a method since we already have the attribute that does the exact same thing.
What do you think?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.