Commit Graph

166 Commits

Author SHA1 Message Date
Tim Griesser 6220d85513 fix: proper typings for edge extension 2020-11-27 13:09:10 -05:00
Tim Griesser 71ea266c9a feat: #479, allow promise to be returned from pageInfoFromNodes 2020-11-27 13:09:10 -05:00
Tim Griesser bb136009c0 feat: #399, add requireResolver: false
Will skip requiring global extension fields
2020-11-27 13:08:57 -05:00
Tim Griesser af7c06ce9d feat: #515, connection can accept non-String cursor 2020-11-27 13:08:50 -05:00
Tim Griesser 8d14709311 fix: #450 - custom edge fields not resolved 2020-11-27 13:05:36 -05:00
Tim Griesser 2dd90b4d87
fix: #618 Add inputFieldDefTypes for declarativeWrappingPlugin (#682) 2020-11-27 12:20:50 -05:00
Tim Griesser 24a78e8cf4
fix: #670 - explicit nullability for connectionPlugin (#671) 2020-11-25 09:49:27 -05:00
Tim Griesser 15515069c1
feat: Improved description for types on output method / output field (#666) 2020-11-24 11:40:55 -05:00
Tim Griesser 5ab7dd35d1
feat: Simplified upgrade path w/ better warning messages (#663)
Co-authored-by: Jason Kuhrt <jason.kuhrt@dialogue.co>
2020-11-24 11:40:38 -05:00
Tim Griesser 57bb5b078b
fix: Ensure we can modify nullability of an interface field (#662) 2020-11-23 22:13:59 -05:00
Tim Griesser 5c73102819
fix: Fix #622, custom scalars should work with interfaceType (#661) 2020-11-23 21:38:28 -05:00
Tim Griesser eb04d8f572
fix: SDL converter list/nonNull chaining (#660) 2020-11-23 16:52:17 -05:00
Tim Griesser bff7008a6b
chore: resolveType warning, restore declarativeWrapping list behavior (#658) 2020-11-23 14:41:59 -05:00
Tim Griesser 306dbaae10
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>
2020-11-23 10:41:03 -05:00
Jason Kuhrt 618521dea0
feat(config): SDL file generation by default in development (#652)
Co-authored-by: Tim Griesser <tgriesser10@gmail.com>

closes #632

BREAKING CHANGE:

SDL file generation will be enabled by default in development now.

If you were enabling it manually before and outputting to project root at `schema.graphql` You can probably now just rely on the default.

If you were relying on the default to disable SDL file generation before then now you need to pass an explicit false:

```ts
makeSchema({
  outputs: {
    schema: false
  }
})
```
2020-11-23 09:51:24 -05:00
Tim Griesser ab4b627acb
chore: Restore integration codegen removed in #629 and #630 (#654) 2020-11-21 17:02:58 -05:00
Tim Griesser 481e2c77fe
feat: Allow contextType to specify an TypingImport config (#606)
Co-authored-by: Flavian DESVERNE <flavian.desverne@epitech.eu>
Co-authored-by: Jason Kuhrt <jasonkuhrt@me.com>
2020-11-20 11:00:18 -05:00
Tim Griesser 4f4f9f49e8
feat(plugin): add onFieldDefinition / onArgDefinition / onInputFieldDefinition (#640) 2020-11-19 11:50:14 +01:00
Tim Griesser e2c88ea3f0 chore: fix types in nullabilityGuardPlugin spec 2020-11-18 22:59:37 -05:00
Tim Griesser 1e11720e00
chore: Refine exports for plugins (#639) 2020-11-18 22:06:32 -05:00
Tim Griesser bfcc959fd6
feat: add t.modify API for modifying inherited fields (#634)
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.
2020-11-18 21:58:14 -05:00
Tim Griesser 94ba687f1e
feat: deprecate plugin onInstall return for consistent API (#637) 2020-11-18 17:01:27 -05:00
Flavian Desverne de832e79ca
feat: replace list & nullable API by type wrappers (#538)
This PR removes the `nullable: boolean` and `list: boolean | boolean[]` API and replaces it with top-level type wrappers named: `list()`, `nonNull()` and `nullable()`
2020-11-18 17:59:59 +01:00
Tim Griesser 9ba7d9b702
refactor: Simplify typegen with keyof and intersection types (#628) 2020-11-17 13:17:22 -05:00
Flavian Desverne 5a8fcae3bd
chore: run integration tests separately (#630) 2020-11-17 18:31:13 +01:00
Flavian Desverne d5b8ea73da
chore: fix tests (#629)
- removes typegenPrinter.spec.ts generated artifacts
2020-11-17 17:16:37 +01:00
Flavian DESVERNE 0c4023bc6f chore: fix test 2020-11-13 20:25:20 +01:00
Flavian DESVERNE 6107b063ca chore: fix test 2020-11-13 20:24:50 +01:00
Flavian Desverne 967d2df73e
feat: improve abstract types (#602)
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
    }
  }
})
```
2020-11-13 20:19:15 +01:00
Tim Griesser 2e9333849d
fix: deduplicate interfaces implementing interfaces (#608) 2020-11-05 13:12:13 -05:00
Jason Kuhrt f60938079a
improve: remove resolver shorthands (#592)
closes #582

As discussed. In most cases resolver shorthands are not a serious use of the API.

BREAKING CHANGE:

Resolver shorthand API is now removed. The following will now not typecheck:

```ts
t.string('foo', () => ... )
```

Instead use:

```ts
t.string('foo', { resolve: () => ... })
```

Runtime support is still intact but will result in a logged warning. Runtime support will be removed in the next Nexus release.
2020-11-04 12:03:29 -05:00
Tim Griesser b19e83ebfc
feat: Allow specifying a node module for type imports (#604) 2020-11-03 15:29:10 -05:00
Tim Griesser 0064dc9be4
fix: #588, #384 non-null list items & connection nullability (#598)
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.
2020-11-02 13:18:28 -05:00
Jason Kuhrt 9f01342248
improve: remove dynamic output builtins (#590)
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.
2020-10-30 10:19:15 -04:00
Santi Albo 9bfdf2cdc5
feat: allow interfaces to implement other interfaces (#496)
closes #389
2020-10-26 10:46:43 -04:00
Flavian Desverne 10c5f8bc8c
fix: "union too complex to represent" for large union types (#571)
Closes #503
Co-authored-by: Jason Kuhrt <jasonkuhrt@me.com>
2020-10-26 10:34:14 -04:00
Flavian Desverne de7cdfd396
fix: connection plugin (#569)
fixes #402
fixes #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)
2020-10-26 09:24:20 -04:00
Jason Kuhrt 083c1ad981 test: capture union too large error 2020-10-22 16:08:00 -04:00
Jason Kuhrt 76e6eff6a0 test: improve connection plugin tests
This deals with spec ambiguity raised in #490
2020-10-20 14:30:24 -04:00
Jason Kuhrt 2edfcfa629
fix: subscription type static typings (#564)
fixes #559
2020-10-20 11:13:08 -04:00
Flavian Desverne f8d164aee7
fix: error if root typing path is invalid (#557)
closes #396
2020-10-20 11:06:00 -04:00
Flavian Desverne 10208e3332
fix: input fields with default should not be typed as optional (#563) 2020-10-19 15:27:08 +02:00
Tim Griesser b4e0debd95
feat: add onObjectDefinition / onInputObjectDefinition (#533) 2020-10-07 13:08:43 -04:00
Flavian Desverne c7eff85edd
feat: output types & list items are now nullable by default (#508)
BREAKING CHANGE:
- output types are now nullable by default. Type! -> Type
- list items are now nullable by default. [Type!] -> [Type]
2020-09-30 15:53:48 +02:00
Santi Albo 3c38a65eb0
fix: message for missing resolveType in interfaces (#495) 2020-08-26 15:42:26 -04:00
Jason Kuhrt 0ee644b234
feat(deps)!: upgrade to graphql v15 (#486)
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.
2020-08-07 16:12:15 -04:00
Émile Fugulin 1d97b788b5
feat: allow asNexusMethod to specify TS type (#473)
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']
```
2020-08-04 09:50:09 -04:00
Jason Kuhrt 903ceb86d4
feat: add subscriptionType (#462) 2020-07-07 18:23:21 -04:00
Jason Kuhrt 78af75686d
chore: format with prisma-labs prettier config (#461) 2020-07-01 23:42:06 -04:00
Jason Kuhrt 9c8e7762fa
feat: support typescript 3.9 (#459)
One internal type error was raised with 3.9 that wasn't before.

This might have led to end-users having to enable skipLibCheck?

For the uncertainty, treating this as a feature as opposed to a chore.
2020-07-01 23:06:45 -04:00
Jason Kuhrt 122b0e17b0
feat: base hasNextPage in connectionPlugin upon gt not gte (#458)
closes #392

BREAKING CHANGE:

Remember that internally Nexus Schema over-fetches by 1 but hides this internally.

It used to be that `SomeEdge.hasNextPage` would be `true` _if_ the number of returned nodes was greater-than OR equal-to the `first` arg value given in the query.

Now when Nexus Schema treats the `equal-to` case as `SomeEdge.hasNextPage` being `false`.

Co-authored-by: Eyal Wiener <eyalwiener@gmail.com>
2020-07-01 16:16:09 -04:00
Leonardo Dino 5b900b156a
fix(connectionPlugin): allow first and last to be zero (#436)
Co-authored-by: Jason Kuhrt <jason.kuhrt@dialogue.co>
2020-07-01 14:49:09 -04:00
Jason Kuhrt bf0df64ebd
tests: add windows to os matrix (#405) 2020-06-10 10:02:04 -04:00
Jason Kuhrt 17fad3a78a chore: update snapshots 2020-04-07 11:19:59 -04:00
Jason Kuhrt cd08bb2a6d refactor: update lang headers 2020-04-07 11:14:08 -04:00
Jason Kuhrt 3156f9bc46 refactor(style): sort imports 2020-04-07 08:19:45 -04:00
Jason Kuhrt fc627fdcd8
fix: schema component import refs (#403)
Also migrates to GH Actions away from CircleCI
2020-03-30 16:14:47 -04:00
Jason Kuhrt 8b1a760019 feat: switch over to component package 2020-03-30 14:47:35 -04:00
Jason Kuhrt 5f7c9708a4 Revert "feat: make sdl-converter use component package"
This reverts commit ec7f22a868.
2020-03-30 14:17:08 -04:00
Jason Kuhrt ec7f22a868 feat: make sdl-converter use component package 2020-03-30 14:11:52 -04:00
Bjorn Lu 14fcbcdc22
feat: Add queryComplexityPlugin for query cost analysis (#369)
* Add graphql-query-complexity package

* Add query complexity plugin

* Add tests

* Add example

* Add docs

* Remove redundant async
2020-02-10 19:00:45 -05:00
Lukáš Huvar 2f4107ebbb
feat: add name to fieldConfig (#368) 2020-02-10 18:49:52 -05:00
Tim Griesser 2090a6ae36
Fix iteration if # nodes requested > connection length (#365) 2020-01-22 21:35:43 -05:00
Tim Griesser 4351a1d051
feat: Add connectionPlugin for relay style pagination (#324)
Adds `connectionsPlugin` for cursor style connections. These adhere to the Relay specification and offer plenty of options for customization:

https://facebook.github.io/relay/graphql/connections.htm
2020-01-22 20:17:17 -05:00
Tim Griesser 88b96042cc
fix: #361, error when using interfaceType & implements (#362)
* fix: #361, error when using interfaceType & implements

* Fix coverage, improve coverage in a few other places while we're here
2020-01-22 15:31:01 -05:00
Dan Lepadatu 6244c4f63a Update warn message when specifying .list and list: true for inputObject (#352) 2019-12-20 09:42:39 -05:00
Tim Griesser 8c9c29aa9c
feat: Add customPrintSchemaFn to makeSchema config (#326)
* feat: Add customPrintSchemaFn to makeSchema config

* Add the code to make the new option work correctly
2019-11-20 08:09:47 -05:00
Tim Griesser 50bf2981e7
feat(epic): 0.12.0 Plugin System and Internal Refactor (#242)
See #242 for a full summary
2019-11-07 16:39:33 -05:00
Jason Kuhrt bac64560e7
feat(plugins): onInstall hook (#236) 2019-10-16 22:55:53 +02:00
Jason Kuhrt 62a6006c64 tests: remove invalid case
Being able to build with type checking on but without typegen is not
inteded to be supported. The following workflows for example are:

1. --transpile-only development builds
2. IDE feedback based on types + typegen
3. production builds where no --transpile-only check is used, based on types + typegen
2019-10-16 22:41:51 +02:00
Jason Kuhrt 573096eff9 fix(typegen): correct default typegen @types path! 2019-10-07 21:51:44 -04:00
Jason Kuhrt 80f1e69f9e chore: fix tests 2019-10-07 21:39:42 -04:00
Jason Kuhrt eb963da09e
feat(config): env var for should-generate-artifacts (#244)
This allows setting the `shouldGenerateArtifacts` config option by env var `NEXUS_SHOULD_GENERATE_ARTIFACTS`
2019-10-07 20:59:15 -04:00
Jason Kuhrt 9ceb53216a
feat(typegen): nicer generated package name (#248)
* feat(typegen): nicer generated package name

This can impact the end-user when they, for example, are using the `types` TS compiler option. In that situation, expressing a whitelist of TypeScript type-packages, in a Nexus app, it would be important that the user also include typegen or else tsc would stop seeing it (forcing the
user to do Nexus typegen config). To make it easier for users to do that, this change allows them refer to a pretty name, rather than something hard to predict, remember, and ugly looking.
2019-10-07 20:51:28 -04:00
Jason Kuhrt 10f5198021
refactor: clean up config processing & tests (#246)
* refactor: clean up config processing & tests

* refactor
2019-10-04 11:09:22 -04:00
Jason Kuhrt aa41026438 fix(config): correct default output paths 2019-10-03 20:34:11 -04:00
Jason Kuhrt 013a606548
feat: by default typegen as an @types package (#230) 2019-10-03 14:25:01 -04:00
Jason Kuhrt 7a3750b025
chore: simplify tsconfig (#240) 2019-10-03 12:37:46 -04:00
Jason Kuhrt 9727c0ee86 chore: apply prettier to test code 2019-09-27 09:12:54 -04:00
Jason Kuhrt e2b75fc36d
refactor: simplify integration test (#228) 2019-09-23 16:35:34 -04:00
Tim Griesser 79788ba874
Remove file:. from devDependencies (#227) 2019-09-23 15:07:30 -04:00
Tim Griesser 9f4ab9d830
Improving code coverage (#225)
* Improving overall coverage
* Improve jest config
* Remove unused internal builder methods
* Prefer non-inline snapshots
2019-09-22 21:28:27 -04:00
Jason Kuhrt e24dd6fb93 docs: remove mention of @prisma/nexus 2019-09-02 21:18:39 -04:00
Jason Kuhrt 7aaea5ef4f
fix(dynamic): typegen for dynamicOutputProperty (#212) 2019-09-01 09:32:57 -04:00
Andrea Di Giorgi 8e3254d023 fix(sdl-converter): object description, enum member deprecation (#204) 2019-08-21 22:29:35 -04:00
Jason Kuhrt 38fe229a19
fix: type errors w/ simple typegens (#191) 2019-08-15 17:48:42 -04:00
Tim Griesser 41fe99dfed
Add dynamicObjectProperty, fix #161 (#178)
* Add dynamicObjectProperty, fix #161
2019-07-14 20:21:13 -04:00
Alejandro Estrada 5c8eb7a4b6 Fix inline functions for custom scalars (#174)
* Fix inline fuctions for custom scalars

* Add test to resolve custom scalar with inline function
2019-07-07 22:28:50 -04:00
Flavian Desverne 611a19b6a0
[RFR] Allow schema construction even with unknown types (#155)
* Allow schema construction even with unknown types

* Fix TS type errors
2019-06-26 19:39:24 +02:00
Pascal Sthamer b1089a5665 Fix wrong fieldName type on subscriptionField (and fix backingTypes.spec.ts) (#159)
* Fix wrong fieldName type on subscriptionField

Closes #158

* Try to fix backingTypes.spec.ts

* Remove unused NexusSchemaExtensions import
2019-06-19 11:08:25 +02:00
Tim Griesser c141ce2fce Allow referencing backing types via rootTypings in codegen 2019-06-11 08:38:22 -04:00
Rutger Hendrickx 459f3cfff1 Allow enum backing types (#142)
* Allow enums to have backing types

* Update typeMatch regex references

* Ignore const enums for backing-types.

* Allow native TS enum as members config

* Allow const enum backing types

* Add assertValidName for enum keys
2019-06-05 08:55:07 -04:00
Tim Griesser 1e932eb4b5
Initial pass at dynamic field inclusion/definition (#143)
* Initial pass at dynamic field inclusion/definition

* Split input/output custom fields, fixes #93 and #129

* Bump some lib versions

* Change around some dynamic field implementation details

* Make args override collection args

* Rename dynamicField -> dynamicMethod, export types from root

* Add decorateType, ability to specify rootType, fixes #17
2019-06-02 20:29:53 -04:00
Tim Griesser 09abed674a
.list on custom scalar type (#141)
* Fix #114 - .list on custom scalar type
2019-05-16 23:44:26 -04:00
Tim Griesser b1be4e2124
Fix #89, SDL converter for list w/ null items (#90) 2019-03-18 11:12:26 -04:00
Tim Griesser 48bb3e92b0 Fix nested nullability 2019-03-18 11:10:57 -04:00
Tim Griesser f1175c0c21
Add extendInputType (#54)
* Add extendInputType, fix #51
2019-02-22 17:29:01 -05:00
Tim Griesser ee1589ae8c
Fix #44, add correct typing for union types (#45) 2019-02-18 18:04:46 -05:00
Kento Moriwaki e6d6fa2611 Fix sdlConverter to export as commonjs (#42)
* Add specs to sdlConverter with commonjs option
* Use export const for esmodules
2019-02-18 10:48:42 -05:00
Tim Griesser c0612e692d Print unions correctly in SDL converter 2019-02-15 00:19:50 -05:00