* Use ReadonlArray when generating output types
* Add useReadonlyArrayForInputs config and use it accordingly
* Update tests snapshots
* Move useReadonlyArrayForInputs in ConfiguredTypegen option
* Add tests for useReadonlyArrayForInputs
Co-authored-by: Jason Kuhrt <jasonkuhrt@me.com>
Co-authored-by: Tim Griesser <tgriesser10@gmail.com>
- Adds a new feature mergeSchema to the makeSchema config, to consume an external schema and merge with the locally defined Nexus types
- Standardizes the consumption of external GraphQLNamedType's so they are converted into Nexus type definitions, simplifying code paths
- Order of resolution goes from local Nexus types -> graphql-js types -> external schema types
- Adds asNexusMethod to all types, allowing for any commonly used types to be used as methods, not just scalars
- Convert methods / properties from protected -> private in Builder to better detect unused code
- Add Maybe on resolveType to match GraphQL signature
- Don't create placeholder Query type when renamed
- Internal rename rootTypings -> sourceTypings
Co-authored-by: Jason Kuhrt <jasonkuhrt@me.com>
COMPLETES INITIAL DEVELOPMENT
BREAKING CHANGE:
You will now need to install Nexus Schema from the npm package `nexus` instead of `@nexus/schema`.
BREAKING CHANGES:
- `contextType` is no longer nested in `typegenAutoConfig`
- `contextType` can no longer references `sources` registered in `typegenAutoConfig`
- `contextType` API was refactored to use `module` instead of `path` and `export` instead of `name`
- `rootTyping` API was refactored to use `module` instead of `path` and `export` instead of `name`
- Renames `EnumTypeConfig` -> `NexusEnumTypeConfig` for consistency
- Adds `.asArg` on `enumType`, since these are often defined inline for one-off field args
- Fixes types so `default` type is properly inferred, eases types elsewhere so valid types which haven't been added to the manifest do not show as type errors
- 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>
Adds `t.modify` API for modifying inherited types.
Use cases:
- If you have an `interface` type, but want to override the resolver or description for the field per-`objectType`
- If an inherited field's value is abstract, and you want to narrow it to a subtype which conforms to the inherited type
- If you want to add additional optional arguments for an inherited field, as is permitted by the spec
The types should validate that only fields inherited from interfaces can be modified, and the `type` can only be
changed if the result of that field is an abstract type which implements the existing inherited return type.
This PR removes the `nullable: boolean` and `list: boolean | boolean[]` API and replaces it with top-level type wrappers named: `list()`, `nonNull()` and `nullable()`
BREAKING CHANGES:
- `isTypeOf` is now the _default_ strategy to discriminate members of an abstract type. To keep using `resolveType` as you might have been before, enable the following config in `makeSchema`:
```ts
makeSchema({
features: {
abstractTypeStrategies: {
resolveType: true
}
}
})
```
Fixes#588 by ensuring that list items follow `nonNullDefaults`, which was lost in the #508 refactor
Fixes#384 by removing explicit nullability config from the connection `edges` definition, and also allowing `nonNullDefaults` to be supplied for the connection "types" generated by the creation of a connection field. Allows you to configure both globally in the connection plugin field config, and when the connection field is defined.
closes#581
BREAKING CHANGE:
`ext` is no longer exported. The `relayConnectionField` and `collectionField` dynamic output methods have been removed. In their place try the `connection` plugin.
fixes#402fixes#450
Fixes:
- Global connection field extensions were never executed
- Typings of global connection field extension (root, args and the resolver return type was wrong)
- Typings of local connection field extension (everything was any)
closes#410
BREAKING CHANGE:
The graphql peer dep requirement has been bumped to v15.
No graphql v15 exclusive features have been shipped yet. But this update
sets us up to begin that work.
Support for graphql v14 and lower has been dropped. It may technically work
still (the test suite did not show any major reasons why it won't, for
now/currently) but there is no guarantee about that remaining so in the
future. Internally we are only testing against v15. Certain new grpahqljs
v15 features like interfaces being able to implement other interfaces will
be released in the future.
If you absolutely cannot upgrade from graphql v14 right now then stay with
@nexus/schema v15. But if you also really need a new @nexus/schema feature
on v16+ (future) then you can try your luck with it an older version of
graphqljs.
Co-authored-by: Jason Kuhrt <jasonkuhrt@me.com>
- Create a new `NexusGenScalars` for all scalar types
- Remove scalars from `NexusGenRootTypes` (might be a breaking change, need review)
- Use the `NexusGenScalars` for all non specified (base GraphQL) scalars in `input` and `output` types
- Add `rootTyping` parameter to `asNexusMethod` to allow the user to specify it, otherwise it will fallback to the `backingTypeMap`
BREAKING CHANGE:
The global TS type `NexusGenRootTypes` no longer contains scalars. All scalars now live under a new global TS type named `NexusGenScalars`.
```ts
// before
let foo: NexusGenRootTypes['String']
```
```ts
// after
let foo: NexusGenScalars['String']
```