fix: add deprecated, description, nullable to connectionField (#578)

This commit is contained in:
Tim Griesser 2020-10-27 14:21:30 -04:00 committed by GitHub
parent 2aaaf5cb9f
commit cc12ec16fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 55 additions and 10 deletions

View File

@ -26,7 +26,7 @@ const schema = makeSchema({
],
contextType: 't.Context',
},
prettierConfig: require.resolve('../../../package.json'),
prettierConfig: require.resolve('../../../.prettierrc'),
})
const store = createStore()

View File

@ -26,5 +26,5 @@ export const schema = makeSchema({
Date: 'Date',
},
},
prettierConfig: require.resolve('../../../package.json'),
prettierConfig: require.resolve('../../../.prettierrc'),
})

View File

@ -10,7 +10,7 @@ const schema = makeSchema({
schema: path.join(__dirname, '../githunt-api-schema.graphql'),
typegen: path.join(__dirname, './githunt-typegen.ts'),
},
prettierConfig: require.resolve('../../../package.json'),
prettierConfig: require.resolve('../../../.prettierrc'),
})
const server = new ApolloServer({

View File

@ -146,6 +146,27 @@ type Query {
): BooleanConnection
complexQuery(count: Int!): [ComplexObject]
dateAsList: [Date]
deprecatedConnection(
"""
Returns the elements in the list that come after the specified cursor
"""
after: String
"""
Returns the elements in the list that come before the specified cursor
"""
before: String
"""
Returns the first n elements from the list.
"""
first: Int
"""
Returns the last n elements from the list.
"""
last: Int
): BooleanConnection! @deprecated(reason: "Dont use this, use booleanConnection instead")
extended: SomeItem
getNumberOrNull(a: Int!): Int
guardedConnection(
@ -200,6 +221,10 @@ type Query {
"""
first: Int!
): UserConnection
"""
A connection with some user nodes
"""
usersConnectionNodes(
"""
Returns the elements in the list that come after the specified cursor

View File

@ -43,7 +43,7 @@ const schema = makeSchema({
},
}),
],
prettierConfig: require.resolve('../../../package.json'),
prettierConfig: require.resolve('../../../.prettierrc'),
})
const server = new ApolloServer({

View File

@ -204,6 +204,15 @@ export const Query = objectType({
},
})
t.connectionField('deprecatedConnection', {
type: 'Boolean',
deprecation: 'Dont use this, use booleanConnection instead',
nullable: false,
nodes() {
return [true]
},
})
t.connectionField('guardedConnection', {
type: 'Date',
disableBackwardPagination: true,
@ -217,6 +226,7 @@ export const Query = objectType({
t.connectionField('usersConnectionNodes', {
type: User,
description: 'A connection with some user nodes',
cursorFromNode(node, args, ctx, info, { index, nodes }) {
if (args.last && !args.before) {
const totalCount = USERS_DATA.length

View File

@ -201,6 +201,7 @@ export interface NexusGenFieldTypes {
booleanConnection: NexusGenRootTypes['BooleanConnection'] | null // BooleanConnection
complexQuery: Array<NexusGenRootTypes['ComplexObject'] | null> | null // [ComplexObject]
dateAsList: Array<NexusGenScalars['Date'] | null> | null // [Date]
deprecatedConnection: NexusGenRootTypes['BooleanConnection'] // BooleanConnection!
extended: NexusGenRootTypes['SomeItem'] | null // SomeItem
getNumberOrNull: number | null // Int
guardedConnection: NexusGenRootTypes['DateConnection'] | null // DateConnection
@ -310,6 +311,7 @@ export interface NexusGenFieldTypeNames {
booleanConnection: 'BooleanConnection'
complexQuery: 'ComplexObject'
dateAsList: 'Date'
deprecatedConnection: 'BooleanConnection'
extended: 'SomeItem'
getNumberOrNull: 'Int'
guardedConnection: 'DateConnection'
@ -396,6 +398,13 @@ export interface NexusGenArgTypes {
// args
count: number // Int!
}
deprecatedConnection: {
// args
after?: string | null // String
before?: string | null // String
first?: number | null // Int
last?: number | null // Int
}
getNumberOrNull: {
// args
a: number // Int!

View File

@ -31,5 +31,5 @@ export const schema = makeSchema({
],
contextType: 'swapi.ContextType',
},
prettierConfig: require.resolve('../../../package.json'),
prettierConfig: require.resolve('../../../.prettierrc'),
})

View File

@ -29,7 +29,7 @@ export const schema = makeSchema({
},
// debug: true,
},
prettierConfig: require.resolve('../../../package.json'),
prettierConfig: require.resolve('../../../.prettierrc'),
})
/**

View File

@ -34,7 +34,7 @@
"clean": "rm -rf dist*",
"deploy-site": "yarn && yarn build",
"dev": "tsc -p tsconfig.cjs.json -w",
"dev:examples": "yarn -s link-examples && tsc -w",
"dev:examples": "yarn -s link-examples && yarn dev",
"dev:test": "jest --watch",
"examples": "yarn link-examples && yarn gulp run-examples",
"format": "prettier --write 'src/**/*.ts' 'tests/**/*.ts' 'examples/*/src/**.ts'",

View File

@ -34,11 +34,11 @@ gulp.task('link-examples', async () => {
})
gulp.task('api-tsc', () => {
runService('yarn', 'tsc -w -p api/tsconfig.json', { stdio: 'ignore' })
runService('yarn', 'tsc -w -p api/tsconfig.cjs.json', { stdio: 'ignore' })
})
gulp.task('core-tsc', () => {
runService('yarn', 'tsc -w -p tsconfig.json', {
runService('yarn', 'tsc -w -p tsconfig.cjs.json', {
stdio: 'ignore',
cwd: path.join(__dirname, '..'),
})

View File

@ -1,6 +1,6 @@
import { GraphQLFieldResolver, GraphQLResolveInfo } from 'graphql'
import { ArgsRecord, intArg, stringArg } from '../definitions/args'
import { FieldOutConfig } from '../definitions/definitionBlocks'
import { CommonFieldConfig, FieldOutConfig } from '../definitions/definitionBlocks'
import { ObjectDefinitionBlock, objectType } from '../definitions/objectType'
import { AllNexusOutputTypeDefs } from '../definitions/wrapping'
import { dynamicOutputMethod } from '../dynamicMethod'
@ -246,6 +246,7 @@ export type ConnectionFieldConfig<TypeName extends string = any, FieldName exten
nodes?: never
}
) &
Pick<CommonFieldConfig, 'deprecation' | 'description' | 'nullable'> &
NexusGenPluginFieldConfig<TypeName, FieldName>
const ForwardPaginateArgs = {