* 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
- 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
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#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)
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']
```