-
-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default nullability #297
Comments
Fields are not nullable by default because properties in TypeScript are not optional by default, so it's much more intuitive design. Also marking With #296 the problem will be gone as you will have 1:1 sync with TS types 😉
You can create a decorator alias: |
Thanks for the response. I’m a little confused by the second paragraph.
Surely making things non nullable by default means that you have !
everywhere?
…On Sun, 31 Mar 2019 at 22:36 Michał Lytek ***@***.***> wrote:
Fields are not nullable by default because properties in TypeScript are
not optional by default, so it's much more intuitive design.
Also marking ! and !]! almost everything in my schema SDL drove me crazy,
so I've decided that fields are not nullable by default.
With #296 <#296> the
problem will be gone as you will have 1:1 sync with TS types :P
Is there a way to change this default?
You can create a decorator alias: const NullableField = () => Field({
nullable: true });.
Maybe I should provide it in out of the box 🤔
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#297 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AC8oXw0BvPduRSEMKocRwnnpSKmPMzEWks5vcQ4rgaJpZM4cUVIP>
.
|
class Foo {
bar: string;
baz: string[];
fooBar(baz: string): string {}
} type Foo {
bar: String!
baz: [String!]!
fooBar(baz: String!): String!
}
I am trying to say that before TypeGraphQL I was creating GraphQL APIs using SDL and I was forgetting about placing |
Thanks for the great work!
…On Thu, 4 Apr 2019 at 17:33 Michał Lytek ***@***.***> wrote:
@elie222 <https://github.com/elie222>
I think that I shouldn't force this behavior, it should be configurable
with current setting as a default one, event with #45
<#45>.
Will try to make this possible soon 😉
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#297 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AC8oX5xVVBbq7I10l3ssQyyzkcQQxZqzks5vdg00gaJpZM4cUVIP>
.
|
@19majkel94 |
GraphQL schema fields are nullable by default, but using TypeGraphQL everything is required by default. Is there a way to change this default?
If I make a GQL request and a certain field is null, the server throws an error. Getting a null for that field instead of an exception seems to be far better default behaviour.
The text was updated successfully, but these errors were encountered: