Skip to content

Commit df7d137

Browse files
authored
feat: field config with name (#938)
1 parent ebcdb29 commit df7d137

32 files changed

+540
-346
lines changed

.github/workflows/pr.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v2
11-
- uses: actions/setup-node@v1
11+
- uses: actions/setup-node@v2
1212
with:
1313
node-version: 12.x
1414
- name: Install Dependencies
@@ -23,12 +23,12 @@ jobs:
2323
test:
2424
strategy:
2525
matrix:
26-
node-version: [10.x, 12.x]
26+
node-version: [12.x, 14.x]
2727
os: [macos-latest, ubuntu-latest, windows-latest]
2828
runs-on: ${{ matrix.os }}
2929
steps:
3030
- uses: actions/checkout@v2
31-
- uses: actions/setup-node@v1
31+
- uses: actions/setup-node@v2
3232
with:
3333
node-version: ${{ matrix.node-version }}
3434
- name: Install Dependencies
@@ -58,12 +58,12 @@ jobs:
5858
# rm examples/star-wars/star-wars-schema.graphql
5959
# node examples/star-wars/dist/schema.js
6060
# git diff --exit-code
61-
node-version: [10.x]
61+
node-version: [12.x]
6262
os: [macos-latest]
6363
runs-on: ${{ matrix.os }}
6464
steps:
6565
- uses: actions/checkout@v2
66-
- uses: actions/setup-node@v1
66+
- uses: actions/setup-node@v2
6767
with:
6868
node-version: ${{ matrix.node-version }}
6969
- name: Install Dependencies
@@ -85,7 +85,7 @@ jobs:
8585
- uses: actions/checkout@v2
8686
with:
8787
fetch-depth: 0
88-
- uses: actions/setup-node@v1
88+
- uses: actions/setup-node@v2
8989
- name: Install Dependencies
9090
run: yarn --frozen-lockfile || yarn --frozen-lockfile
9191
- name: Prettier

.github/workflows/trunk.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v2
12-
- uses: actions/setup-node@v1
12+
- uses: actions/setup-node@v2
1313
with:
1414
node-version: 12.x
1515
- name: Install Dependencies
@@ -22,12 +22,12 @@ jobs:
2222
test:
2323
strategy:
2424
matrix:
25-
node-version: [10.x, 12.x]
25+
node-version: [12.x, 14.x]
2626
os: [macos-latest, ubuntu-latest, windows-latest]
2727
runs-on: ${{ matrix.os }}
2828
steps:
2929
- uses: actions/checkout@v2
30-
- uses: actions/setup-node@v1
30+
- uses: actions/setup-node@v2
3131
with:
3232
node-version: ${{ matrix.node-version }}
3333
- name: Install Dependencies
@@ -57,12 +57,12 @@ jobs:
5757
# rm examples/star-wars/star-wars-schema.graphql
5858
# node examples/star-wars/dist/schema.js
5959
# git diff --exit-code
60-
node-version: [10.x]
60+
node-version: [12.x]
6161
os: [macos-latest]
6262
runs-on: ${{ matrix.os }}
6363
steps:
6464
- uses: actions/checkout@v2
65-
- uses: actions/setup-node@v1
65+
- uses: actions/setup-node@v2
6666
with:
6767
node-version: ${{ matrix.node-version }}
6868
- name: Install Dependencies
@@ -85,7 +85,7 @@ jobs:
8585
- uses: actions/checkout@v2
8686
with:
8787
fetch-depth: 0
88-
- uses: actions/setup-node@v1
88+
- uses: actions/setup-node@v2
8989
- name: Install Dependencies
9090
run: yarn --frozen-lockfile || yarn --frozen-lockfile
9191
- name: Release Canary

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@
9393
"jest-watch-typeahead": "^0.6.1",
9494
"lint-staged": "^7.3.0",
9595
"patch-package": "6.2.2",
96-
"prettier": "^2.2.1",
97-
"prettier-plugin-jsdoc": "^0.2.5",
96+
"prettier": "^2.3.1",
97+
"prettier-plugin-jsdoc": "^0.3.23",
9898
"sort-package-json": "^1.22.1",
9999
"ts-jest": "^26.4.4",
100100
"ts-morph": "^8.2.0",

src/builder.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,8 @@ export class SchemaBuilder {
453453

454454
/**
455455
* Add type takes a Nexus type, or a GraphQL type and pulls it into an internal "type registry". It also
456-
* does an initial pass on any types that are referenced on the "types" field and pulls those in too, so
457-
* you can define types anonymously, without exporting them.
456+
* does an initial pass on any types that are referenced on the "types" field and pulls those in too, so you
457+
* can define types anonymously, without exporting them.
458458
*/
459459
addType = (typeDef: NexusAcceptedTypeDef) => {
460460
if (isNexusMeta(typeDef)) {

src/definitions/_types.ts

+13-16
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,12 @@ export type NexusFeaturesInput = {
175175
* types guide](https://nxs.li/guides/abstract-types).
176176
*
177177
* If you plan on enabling multiple strategies and you've never done so then please [read the guide about
178-
* using multiple strategies](https://nxs.li/guides/abstract-types/using-multiple-strategies) as there are
179-
* a few quirks to be aware of.
178+
* using multiple strategies](https://nxs.li/guides/abstract-types/using-multiple-strategies) as there are a
179+
* few quirks to be aware of.
180180
*
181-
* @default
182-
* {
183-
* resolveType: true,
181+
* @default {resolveType: true,
184182
* __typename: false
185-
* isTypeOf: false,
186-
* }
183+
* isTypeOf: false,}
187184
*/
188185
abstractTypeStrategies?: {
189186
/**
@@ -206,16 +203,16 @@ export type NexusFeaturesInput = {
206203
* the [Discriminant Model Field Strategy](https://nxs.li/guides/abstract-types/discriminant-model-field-strategy).
207204
*
208205
* Warning :: When this strategy is enabled in conjunction with other strategies the
209-
* "abstractTypeRuntimeChecks" feature will automatically be disabled. This is because it is not
210-
* practical at runtime to find out if resolvers will return objects that include the "__typename" field.
211-
* This trade-off can be acceptable since the runtime checks are a redundant safety measure over the
212-
* static typing. So as long as you are not ignoring static errors related to Nexus' abstract type type
213-
* checks then you then you should still have a safe implementation.
206+
* "abstractTypeRuntimeChecks" feature will automatically be disabled. This is because it is not practical
207+
* at runtime to find out if resolvers will return objects that include the "__typename" field. This
208+
* trade-off can be acceptable since the runtime checks are a redundant safety measure over the static
209+
* typing. So as long as you are not ignoring static errors related to Nexus' abstract type type checks
210+
* then you then you should still have a safe implementation.
214211
*
215-
* Furthermore another effect is that statically the other strategies will not appear to be _required_,
216-
* but instead _optional_, while only this one will appear required. However, upon implementing any of
217-
* the other strategies, this one will not longer be required. This quirk is explained in the guide
218-
* section about [using multiple strategies](https://nxs.li/guides/abstract-types/using-multiple-strategies).
212+
* Furthermore another effect is that statically the other strategies will not appear to be *required*,
213+
* but instead *optional*, while only this one will appear required. However, upon implementing any of the
214+
* other strategies, this one will not longer be required. This quirk is explained in the guide section
215+
* about [using multiple strategies](https://nxs.li/guides/abstract-types/using-multiple-strategies).
219216
*/
220217
__typename?: boolean
221218
}

src/definitions/args.ts

+8-15
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export interface ScalarArgConfig<T> extends CommonArgConfig {
5353
/**
5454
* The default value for this argument when ***none*** is given by the client.
5555
*
56-
* Note that _null_ is still considered something meaning if the client gives an explicit null that will
56+
* Note that *null* is still considered something meaning if the client gives an explicit null that will
5757
* prevent the default from activating. This is why the type of an arg with a default value in the resolver
5858
* includes "undefined | null".
5959
*
@@ -87,10 +87,8 @@ export interface NexusArgConfig<T extends string> extends NexusAsArgConfig<T> {
8787
* Types may be expressed in one of three ways:
8888
*
8989
* 1. As string literals matching the name of a builtin scalar.
90-
*
9190
* 2. As string literals matching the name of another type. Thanks to [Nexus' reflection
92-
* system](https://nxs.li/guides/reflection) this is typesafe and autocompletable.
93-
*
91+
* system](https://nxs.li/guides/reflection) this is typesafe and autocompletable.
9492
* 3. As references to other enums or input object type definitions.
9593
*
9694
* Type modifier helpers like list() may also be used and in turn accept one of the three methods listed above.
@@ -159,7 +157,7 @@ withNexusSymbol(NexusArgDef, NexusTypes.Arg)
159157
* })
160158
*
161159
* @param config Configuration for the argument like its type and description. See jsdoc on each config field
162-
* for details.
160+
* for details.
163161
*/
164162
export function arg<T extends string>(config: NexusArgConfig<T>) {
165163
if (!config.type) {
@@ -193,8 +191,7 @@ export function arg<T extends string>(config: NexusArgConfig<T>) {
193191
* },
194192
* })
195193
*
196-
* @param config Configuration for the argument like its description. See jsdoc on each config field
197-
* for details.
194+
* @param config Configuration for the argument like its description. See jsdoc on each config field for details.
198195
*/
199196
export function stringArg(config?: ScalarArgConfig<string>) {
200197
return arg({ type: 'String', ...config })
@@ -224,8 +221,7 @@ export function stringArg(config?: ScalarArgConfig<string>) {
224221
* },
225222
* })
226223
*
227-
* @param config Configuration for the argument like its description. See jsdoc on each config field
228-
* for details.
224+
* @param config Configuration for the argument like its description. See jsdoc on each config field for details.
229225
*/
230226
export function intArg(config?: ScalarArgConfig<number>) {
231227
return arg({ type: 'Int', ...config })
@@ -255,8 +251,7 @@ export function intArg(config?: ScalarArgConfig<number>) {
255251
* },
256252
* })
257253
*
258-
* @param config Configuration for the argument like its description. See jsdoc on each config field
259-
* for details.
254+
* @param config Configuration for the argument like its description. See jsdoc on each config field for details.
260255
*/
261256
export function floatArg(config?: ScalarArgConfig<number>) {
262257
return arg({ type: 'Float', ...config })
@@ -286,8 +281,7 @@ export function floatArg(config?: ScalarArgConfig<number>) {
286281
* },
287282
* })
288283
*
289-
* @param config Configuration for the argument like its description. See jsdoc on each config field
290-
* for details.
284+
* @param config Configuration for the argument like its description. See jsdoc on each config field for details.
291285
*/
292286
export function idArg(config?: ScalarArgConfig<string>) {
293287
return arg({ type: 'ID', ...config })
@@ -317,8 +311,7 @@ export function idArg(config?: ScalarArgConfig<string>) {
317311
* },
318312
* })
319313
*
320-
* @param config Configuration for the argument like its description. See jsdoc on each config field
321-
* for details.
314+
* @param config Configuration for the argument like its description. See jsdoc on each config field for details.
322315
*/
323316
export function booleanArg(config?: ScalarArgConfig<boolean>) {
324317
return arg({ type: 'Boolean', ...config })

0 commit comments

Comments
 (0)