Skip to content

Commit

Permalink
feat: field config with name (#938)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Jun 23, 2021
1 parent ebcdb29 commit df7d137
Show file tree
Hide file tree
Showing 32 changed files with 540 additions and 346 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: 12.x
- name: Install Dependencies
Expand All @@ -23,12 +23,12 @@ jobs:
test:
strategy:
matrix:
node-version: [10.x, 12.x]
node-version: [12.x, 14.x]
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
Expand Down Expand Up @@ -58,12 +58,12 @@ jobs:
# rm examples/star-wars/star-wars-schema.graphql
# node examples/star-wars/dist/schema.js
# git diff --exit-code
node-version: [10.x]
node-version: [12.x]
os: [macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
Expand All @@ -85,7 +85,7 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
- name: Install Dependencies
run: yarn --frozen-lockfile || yarn --frozen-lockfile
- name: Prettier
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/trunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: 12.x
- name: Install Dependencies
Expand All @@ -22,12 +22,12 @@ jobs:
test:
strategy:
matrix:
node-version: [10.x, 12.x]
node-version: [12.x, 14.x]
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
Expand Down Expand Up @@ -57,12 +57,12 @@ jobs:
# rm examples/star-wars/star-wars-schema.graphql
# node examples/star-wars/dist/schema.js
# git diff --exit-code
node-version: [10.x]
node-version: [12.x]
os: [macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
Expand All @@ -85,7 +85,7 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
- name: Install Dependencies
run: yarn --frozen-lockfile || yarn --frozen-lockfile
- name: Release Canary
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
"jest-watch-typeahead": "^0.6.1",
"lint-staged": "^7.3.0",
"patch-package": "6.2.2",
"prettier": "^2.2.1",
"prettier-plugin-jsdoc": "^0.2.5",
"prettier": "^2.3.1",
"prettier-plugin-jsdoc": "^0.3.23",
"sort-package-json": "^1.22.1",
"ts-jest": "^26.4.4",
"ts-morph": "^8.2.0",
Expand Down
4 changes: 2 additions & 2 deletions src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,8 @@ export class SchemaBuilder {

/**
* Add type takes a Nexus type, or a GraphQL type and pulls it into an internal "type registry". It also
* does an initial pass on any types that are referenced on the "types" field and pulls those in too, so
* you can define types anonymously, without exporting them.
* does an initial pass on any types that are referenced on the "types" field and pulls those in too, so you
* can define types anonymously, without exporting them.
*/
addType = (typeDef: NexusAcceptedTypeDef) => {
if (isNexusMeta(typeDef)) {
Expand Down
29 changes: 13 additions & 16 deletions src/definitions/_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,12 @@ export type NexusFeaturesInput = {
* types guide](https://nxs.li/guides/abstract-types).
*
* If you plan on enabling multiple strategies and you've never done so then please [read the guide about
* using multiple strategies](https://nxs.li/guides/abstract-types/using-multiple-strategies) as there are
* a few quirks to be aware of.
* using multiple strategies](https://nxs.li/guides/abstract-types/using-multiple-strategies) as there are a
* few quirks to be aware of.
*
* @default
* {
* resolveType: true,
* @default {resolveType: true,
* __typename: false
* isTypeOf: false,
* }
* isTypeOf: false,}
*/
abstractTypeStrategies?: {
/**
Expand All @@ -206,16 +203,16 @@ export type NexusFeaturesInput = {
* the [Discriminant Model Field Strategy](https://nxs.li/guides/abstract-types/discriminant-model-field-strategy).
*
* Warning :: When this strategy is enabled in conjunction with other strategies the
* "abstractTypeRuntimeChecks" feature will automatically be disabled. This is because it is not
* practical at runtime to find out if resolvers will return objects that include the "__typename" field.
* This trade-off can be acceptable since the runtime checks are a redundant safety measure over the
* static typing. So as long as you are not ignoring static errors related to Nexus' abstract type type
* checks then you then you should still have a safe implementation.
* "abstractTypeRuntimeChecks" feature will automatically be disabled. This is because it is not practical
* at runtime to find out if resolvers will return objects that include the "__typename" field. This
* trade-off can be acceptable since the runtime checks are a redundant safety measure over the static
* typing. So as long as you are not ignoring static errors related to Nexus' abstract type type checks
* then you then you should still have a safe implementation.
*
* Furthermore another effect is that statically the other strategies will not appear to be _required_,
* but instead _optional_, while only this one will appear required. However, upon implementing any of
* the other strategies, this one will not longer be required. This quirk is explained in the guide
* section about [using multiple strategies](https://nxs.li/guides/abstract-types/using-multiple-strategies).
* Furthermore another effect is that statically the other strategies will not appear to be *required*,
* but instead *optional*, while only this one will appear required. However, upon implementing any of the
* other strategies, this one will not longer be required. This quirk is explained in the guide section
* about [using multiple strategies](https://nxs.li/guides/abstract-types/using-multiple-strategies).
*/
__typename?: boolean
}
Expand Down
23 changes: 8 additions & 15 deletions src/definitions/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export interface ScalarArgConfig<T> extends CommonArgConfig {
/**
* The default value for this argument when ***none*** is given by the client.
*
* Note that _null_ is still considered something meaning if the client gives an explicit null that will
* Note that *null* is still considered something meaning if the client gives an explicit null that will
* prevent the default from activating. This is why the type of an arg with a default value in the resolver
* includes "undefined | null".
*
Expand Down Expand Up @@ -87,10 +87,8 @@ export interface NexusArgConfig<T extends string> extends NexusAsArgConfig<T> {
* Types may be expressed in one of three ways:
*
* 1. As string literals matching the name of a builtin scalar.
*
* 2. As string literals matching the name of another type. Thanks to [Nexus' reflection
* system](https://nxs.li/guides/reflection) this is typesafe and autocompletable.
*
* system](https://nxs.li/guides/reflection) this is typesafe and autocompletable.
* 3. As references to other enums or input object type definitions.
*
* Type modifier helpers like list() may also be used and in turn accept one of the three methods listed above.
Expand Down Expand Up @@ -159,7 +157,7 @@ withNexusSymbol(NexusArgDef, NexusTypes.Arg)
* })
*
* @param config Configuration for the argument like its type and description. See jsdoc on each config field
* for details.
* for details.
*/
export function arg<T extends string>(config: NexusArgConfig<T>) {
if (!config.type) {
Expand Down Expand Up @@ -193,8 +191,7 @@ export function arg<T extends string>(config: NexusArgConfig<T>) {
* },
* })
*
* @param config Configuration for the argument like its description. See jsdoc on each config field
* for details.
* @param config Configuration for the argument like its description. See jsdoc on each config field for details.
*/
export function stringArg(config?: ScalarArgConfig<string>) {
return arg({ type: 'String', ...config })
Expand Down Expand Up @@ -224,8 +221,7 @@ export function stringArg(config?: ScalarArgConfig<string>) {
* },
* })
*
* @param config Configuration for the argument like its description. See jsdoc on each config field
* for details.
* @param config Configuration for the argument like its description. See jsdoc on each config field for details.
*/
export function intArg(config?: ScalarArgConfig<number>) {
return arg({ type: 'Int', ...config })
Expand Down Expand Up @@ -255,8 +251,7 @@ export function intArg(config?: ScalarArgConfig<number>) {
* },
* })
*
* @param config Configuration for the argument like its description. See jsdoc on each config field
* for details.
* @param config Configuration for the argument like its description. See jsdoc on each config field for details.
*/
export function floatArg(config?: ScalarArgConfig<number>) {
return arg({ type: 'Float', ...config })
Expand Down Expand Up @@ -286,8 +281,7 @@ export function floatArg(config?: ScalarArgConfig<number>) {
* },
* })
*
* @param config Configuration for the argument like its description. See jsdoc on each config field
* for details.
* @param config Configuration for the argument like its description. See jsdoc on each config field for details.
*/
export function idArg(config?: ScalarArgConfig<string>) {
return arg({ type: 'ID', ...config })
Expand Down Expand Up @@ -317,8 +311,7 @@ export function idArg(config?: ScalarArgConfig<string>) {
* },
* })
*
* @param config Configuration for the argument like its description. See jsdoc on each config field
* for details.
* @param config Configuration for the argument like its description. See jsdoc on each config field for details.
*/
export function booleanArg(config?: ScalarArgConfig<boolean>) {
return arg({ type: 'Boolean', ...config })
Expand Down

0 comments on commit df7d137

Please sign in to comment.