Commit Graph

56 Commits

Author SHA1 Message Date
Tim Griesser 9875e90dae
feat: Add Schema Directives to SDL (#952)
Adds directive & addDirective utilities for defining directives emitted in the SDL
2022-05-15 16:59:05 -04:00
Tim Griesser 123dc61fac
fix: incorrect logic in backward pagination (#1084) 2022-05-03 15:35:21 -04:00
Tim Griesser 251af9461b fix: update snapshots for change in #1083 2022-05-03 11:38:57 -04:00
Daniel Schwartz b906288c58
chore: change facebook.github.io to relay.dev links (#1083) 2022-05-03 11:24:45 -04:00
Tim Griesser 0d06f26b12
feat: add GraphQL 16 support (#977) 2022-02-17 12:47:40 -05:00
Tim Griesser 9ec3442539
fix: Minimum GraphQL v16 support (#1017) 2021-11-18 15:53:18 -05:00
Tim Griesser 74c93e2ce4
refactor: add importsNotUsedAsValues: error to force import type (#872) 2021-03-27 16:26:13 -04:00
Tim Griesser 27e35e51ee
fix: reduce iteration in connections (#843) 2021-02-24 13:25:56 -05:00
Tim Griesser aa283addcf
fix: invoke correct fn on global extended connection/edge (#814) 2021-02-01 11:15:32 -05:00
Tim Griesser 1f5b025837
fix: pass down source into extended connection fields (#812) 2021-01-31 23:04:03 -05:00
Tim Griesser fbcfba3165
feat: connectionPlugin internal modifications (#811)
- Adds `(root, ctx)` to `validateArgs`
- Iterate all nodes if neither `first` or `last` are provided, e.g. with custom `validateArgs`
- Export additional internal fns on `connectionPlugin`
2021-01-31 13:38:42 -05:00
Filip Stefansson bb936cb95c
feat: add plugin support for inputObjectType (#799) 2021-01-31 12:32:37 -05:00
Miguel Oller 4f3cef9d38
feat: Add custom name options to Relay Connection plugin (#744) 2021-01-06 22:08:40 -05:00
Flavian Desverne 80ad53135c
improve!: rename package to nexus (#699)
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`.
2020-12-14 09:41:29 -05:00
Flavian Desverne d66e8f10d7 feat: rename typegenAutoConfig and rootTyping (#723)
BREAKING CHANGES:
- Renames `typegenAutoConfig` to `sourceTypes`
- Renames `typegenAutoConfig.sources` to `sourceTypes.modules`
- Renames `typegenAutoConfig.sources[].source` to `sourcesTypes.modules[].module`
- Renames `rootTyping` to `sourceType`
2020-12-10 19:23:23 +01:00
Tim Griesser dc1e21bdad
feat: pass connection args to field extensions (#710) 2020-12-07 17:02:36 -05:00
Tim Griesser 9d0f4f4226
feat: add .asArg for enum, fix default typings (#708)
- 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
2020-12-06 18:52:04 -05:00
Tim Griesser cf5b2695dc
feat: support graphql@^14.5 (#677) 2020-11-27 14:22:48 -05:00
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 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
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 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
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 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
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
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 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 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
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 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 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