Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: .nonNull / .nullable chaining, additional cleanup (#655)
- Fixes SDL conversion - Defer wrapping until types are built - Supports GraphQL types anywhere that a type can be used, wrapped, etc. - Split out the wrapping, w/ `finalizeWrapping` helper which adds in the `NonNull` to the list as needed - Make `nonNull(nonNull(T))` & `nullable(nullable(T))` no-op for simplicity - Change: `nullable(nonNull(T))` will undo the `nonNull` - Properly type-check's `subscriptionType` by passing `Event` generic properly - Adds `declarativeWrappingPlugin` for previous `nullable` / `list` behavior Co-authored-by: Flavian DESVERNE <flavian.desverne@epitech.eu>
- Loading branch information
Showing
54 changed files
with
3,825 additions
and
1,365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
title: Declarative Wrapping (null/list) | ||
--- | ||
|
||
## Declarative Wrapping | ||
|
||
The declarative wrapping plugin adds the pre 0.19 API of `list: true | boolean[]`, `nullable: boolean`, and `required: boolean` | ||
on field & argument definitions. | ||
|
||
To install, add the `declarativeWrapping` to the `makeSchema.plugins` array, along with any other plugins | ||
you'd like to include: | ||
|
||
```ts | ||
import { makeSchema, declarativeWrapping } from '@nexus/schema' | ||
|
||
const schema = makeSchema({ | ||
// ... types, etc, | ||
plugins: [ | ||
// ... other plugins | ||
declarativeWrapping(), | ||
], | ||
}) | ||
``` | ||
|
||
You can now use the object style APIs on any args & field definitions. | ||
|
||
```ts | ||
export const User = objectType({ | ||
name: 'User', | ||
definition(t) { | ||
t.string('someNullField', { | ||
nullable: true, | ||
}) | ||
t.string('someRequiredField', { | ||
nullable: false, | ||
resolve: () => 'Some Field', | ||
}) | ||
t.string('someList', { | ||
list: true, | ||
resolve: () => [], | ||
}) | ||
t.string('someListOfLists', { | ||
list: [true, true], | ||
args: { | ||
int: intArg({ required: true }), | ||
}, | ||
resolve: () => [], | ||
}) | ||
}, | ||
}) | ||
``` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.