Skip to content

Commit

Permalink
Merge branch 'develop' into tgriesser/feat/connection-cleanup-async
Browse files Browse the repository at this point in the history
* develop:
  chore: Prettier on the codebase for JSDoc formatting (#706)
  • Loading branch information
tgriesser committed Dec 6, 2020
2 parents 325b95a + 439864a commit f8f4b9f
Show file tree
Hide file tree
Showing 45 changed files with 324 additions and 663 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
with:
node-version: 12.x
- name: Install Dependencies
run: yarn --frozen-lockfile
run: yarn --frozen-lockfile && yarn format:ci
- name: Install GraphQL@14.x
run: yarn add graphql@^14.5.8
- name: Test
Expand All @@ -30,6 +30,9 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: yarn --frozen-lockfile
- name: Check Prettier
if: matrix.os != 'windows-latest'
run: yarn format:ci
- name: Test
run: yarn -s test:ci
- name: Upload coverage to Codecov
Expand Down Expand Up @@ -61,7 +64,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: yarn --frozen-lockfile
run: yarn --frozen-lockfile && yarn format:ci
- name: Link
run: yarn link
- name: Example Install
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/trunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: yarn --frozen-lockfile
- name: Check Prettier
if: matrix.os != 'windows-latest'
run: yarn format:ci
- name: Test
run: yarn -s test:ci
- name: Upload coverage to Codecov
Expand Down Expand Up @@ -63,7 +66,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: yarn --frozen-lockfile
run: yarn --frozen-lockfile && yarn format:ci
- name: Link
run: yarn link
- name: Example Install
Expand All @@ -82,7 +85,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v1
- name: Install Dependencies
run: yarn --frozen-lockfile
run: yarn --frozen-lockfile && yarn format:ci
- name: Release Canary
env:
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
Expand Down
5 changes: 1 addition & 4 deletions examples/apollo-fullstack/src/fullstack-typegen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/**
* This file was generated by Nexus Schema
* Do not make changes to this file directly
*/
/** This file was generated by Nexus Schema Do not make changes to this file directly */

import * as t from './typeDefs'

Expand Down
5 changes: 2 additions & 3 deletions examples/apollo-fullstack/src/typeDefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ export interface LaunchApi extends RESTDataSource {

export interface UserApi extends DataSource {
/**
* User can be called with an argument that includes email, but it doesn't
* have to be. If the user is already on the context, it will use that user
* instead
* User can be called with an argument that includes email, but it doesn't have to be. If the user is
* already on the context, it will use that user instead
*/
findOrCreateUser(obj?: { email?: string | null }): Promise<DBUser | null>
bookTrips(obj: { launchIds: string[] }): Promise<DBTrip[]>
Expand Down
5 changes: 1 addition & 4 deletions examples/githunt-api/src/githunt-typegen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/**
* This file was generated by Nexus Schema
* Do not make changes to this file directly
*/
/** This file was generated by Nexus Schema Do not make changes to this file directly */

declare global {
interface NexusGen extends NexusGenTypes {}
Expand Down
25 changes: 9 additions & 16 deletions examples/kitchen-sink/src/kitchen-sink.gen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/**
* This file was generated by Nexus Schema
* Do not make changes to this file directly
*/
/** This file was generated by Nexus Schema Do not make changes to this file directly */

import { UnusedInterfaceTypeDef } from './kitchen-sink-definitions'
import { core, connectionPluginCore } from '@nexus/schema'
Expand Down Expand Up @@ -557,24 +554,20 @@ declare global {
}
interface NexusGenPluginFieldConfig<TypeName extends string, FieldName extends string> {
/**
* The complexity for an individual field. Return a number
* or a function that returns a number to specify the
* complexity for this field.
* The complexity for an individual field. Return a number or a function that returns a number to specify
* the complexity for this field.
*/
complexity?: QueryComplexity<TypeName, FieldName>
/**
* Authorization for an individual field. Returning "true"
* or "Promise<true>" means the field can be accessed.
* Returning "false" or "Promise<false>" will respond
* with a "Not Authorized" error for the field.
* Returning or throwing an error will also prevent the
* resolver from executing.
* Authorization for an individual field. Returning "true" or "Promise<true>" means the field can be
* accessed. Returning "false" or "Promise<false>" will respond with a "Not Authorized" error for the
* field. Returning or throwing an error will also prevent the resolver from executing.
*/
authorize?: FieldAuthorizeResolver<TypeName, FieldName>
/**
* The nullability guard can be helpful, but is also a potentially expensive operation for lists.
* We need to iterate the entire list to check for null items to guard against. Set this to true
* to skip the null guard on a specific field if you know there's no potential for unsafe types.
* The nullability guard can be helpful, but is also a potentially expensive operation for lists. We need
* to iterate the entire list to check for null items to guard against. Set this to true to skip the null
* guard on a specific field if you know there's no potential for unsafe types.
*/
skipNullGuard?: boolean
}
Expand Down
29 changes: 9 additions & 20 deletions examples/star-wars/src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ import { Character, Human, Droid } from './types/backingTypes'
*
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* This source code is licensed under the MIT license found in the LICENSE file in the root directory of this
* source tree.
*/

/**
* This defines a basic set of data for our Star Wars Schema.
*
* This data is hard coded for the sake of the demo, but you could imagine
* fetching this data from a backend service rather than from hardcoded
* JSON objects in a more complex demo.
* This data is hard coded for the sake of the demo, but you could imagine fetching this data from a backend
* service rather than from hardcoded JSON objects in a more complex demo.
*/

const luke = {
Expand Down Expand Up @@ -91,25 +90,19 @@ const droidData = {
'2001': artoo,
} as { [key in string]: Droid }

/**
* Helper function to get a character by ID.
*/
/** Helper function to get a character by ID. */
function getCharacter(id: string) {
// Returning a promise just to illustrate GraphQL.js's support.
return Promise.resolve(humanData[id] || droidData[id])
}

/**
* Allows us to query for a character's friends.
*/
/** Allows us to query for a character's friends. */
export function getFriends(character: Character) {
// Notice that GraphQL accepts Arrays of Promises.
return character.friends.map((id) => getCharacter(id))
}

/**
* Allows us to fetch the undisputed hero of the Star Wars trilogy, R2-D2.
*/
/** Allows us to fetch the undisputed hero of the Star Wars trilogy, R2-D2. */
export function getHero(episode?: number | null): Character {
if (episode === 5) {
// Luke is the hero of Episode V.
Expand All @@ -121,18 +114,14 @@ export function getHero(episode?: number | null): Character {

export const allHumans = Object.keys(humanData).map((key) => humanData[key])

/**
* Allows us to query for the human with the given id.
*/
/** Allows us to query for the human with the given id. */
export function getHuman(id: string): Human {
return humanData[id]
}

export const allDroids = Object.keys(droidData).map((key) => droidData[key])

/**
* Allows us to query for the droid with the given id.
*/
/** Allows us to query for the droid with the given id. */
export function getDroid(id: string): Droid {
return droidData[id]
}
5 changes: 1 addition & 4 deletions examples/star-wars/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { makeSchema, nullabilityGuardPlugin } from '@nexus/schema'
import * as path from 'path'
import * as allTypes from './graphql'

/**
* Finally, we construct our schema (whose starting query type is the query
* type we defined above) and export it.
*/
/** Finally, we construct our schema (whose starting query type is the query type we defined above) and export it. */
export const schema = makeSchema({
types: allTypes,
outputs: {
Expand Down
11 changes: 4 additions & 7 deletions examples/star-wars/src/star-wars-typegen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/**
* This file was generated by Nexus Schema
* Do not make changes to this file directly
*/
/** This file was generated by Nexus Schema Do not make changes to this file directly */

import * as swapi from './types/backingTypes'

Expand Down Expand Up @@ -206,9 +203,9 @@ declare global {
interface NexusGenPluginTypeConfig<TypeName extends string> {}
interface NexusGenPluginFieldConfig<TypeName extends string, FieldName extends string> {
/**
* The nullability guard can be helpful, but is also a potentially expensive operation for lists.
* We need to iterate the entire list to check for null items to guard against. Set this to true
* to skip the null guard on a specific field if you know there's no potential for unsafe types.
* The nullability guard can be helpful, but is also a potentially expensive operation for lists. We need
* to iterate the entire list to check for null items to guard against. Set this to true to skip the null
* guard on a specific field if you know there's no potential for unsafe types.
*/
skipNullGuard?: boolean
}
Expand Down
4 changes: 2 additions & 2 deletions examples/ts-ast-reader/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export const schema = makeSchema({
})

/**
* When the type is a "Node", we want to first look for types with
* the name `Node`, e.g. TypeReferenceNode vs TypeReference
* When the type is a "Node", we want to first look for types with the name `Node`, e.g. TypeReferenceNode vs
* TypeReference
*/
function tsTypeMatch(type: GraphQLNamedType, defaultMatch: RegExp) {
if (isNodeType(type)) {
Expand Down
5 changes: 1 addition & 4 deletions examples/ts-ast-reader/src/ts-ast-reader-typegen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/**
* This file was generated by Nexus Schema
* Do not make changes to this file directly
*/
/** This file was generated by Nexus Schema Do not make changes to this file directly */

import * as t from './types/index'
import ts from 'typescript'
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"dev:test": "jest --watch",
"examples": "yarn link-examples && yarn gulp run-examples",
"format": "prettier --write 'src/**/*.ts' 'tests/**/*.ts' 'examples/*/src/**.ts'",
"format:ci": "prettier --check 'src/**/*.ts' 'tests/**/*.ts' 'examples/*/src/**.ts'",
"link-examples": "yarn && yarn gulp link-examples",
"lint": "tslint -p tsconfig.json",
"prepublish": "yarn clean && yarn build",
Expand Down
Loading

0 comments on commit f8f4b9f

Please sign in to comment.