Skip to content

Commit a8833c3

Browse files
Merge pull request #3193 from smolinari/patch-1
docs(resolvers-map): add notes about missing non-value types for nullable fields and args
2 parents 4ba8474 + d77162f commit a8833c3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

content/graphql/resolvers-map.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ getAuthor(
269269
) {}
270270
```
271271

272+
> info **Hint** In the case of `firstName`, which is a GraphQL nullable field, it isn't necessary to add the non-value types of `null` or `undefined` to the type of this field. Just be aware, you'll need to type guard for these possible non-value types in your resolvers, because a GraphQL nullable field will allow those types to pass through to your resolver.
273+
272274
#### Dedicated arguments class
273275

274276
With inline `@Args()` calls, code like the example above becomes bloated. Instead, you can create a dedicated `GetAuthorArgs` arguments class and access it in the handler method as follows:
@@ -295,7 +297,7 @@ class GetAuthorArgs {
295297
}
296298
```
297299

298-
> info **Hint** Again, due to TypeScript's metadata reflection system limitations, it's required to either use the `@Field` decorator to manually indicate type and optionality, or use a [CLI plugin](/graphql/cli-plugin).
300+
> info **Hint** Again, due to TypeScript's metadata reflection system limitations, it's required to either use the `@Field` decorator to manually indicate type and optionality, or use a [CLI plugin](/graphql/cli-plugin). Also, in the case of `firstName`, which is a GraphQL nullable field, it isn't necessary to add the non-value types of `null` or `undefined` to the type of this field. Just be aware, you'll need to type guard for these possible non-value types in your resolvers, because a GraphQL nullable field will allow those types to pass through to your resolver.
299301
300302
This will result in generating the following part of the GraphQL schema in SDL:
301303

0 commit comments

Comments
 (0)