fix: add deprecated, description, nullable to connectionField (#578)
This commit is contained in:
parent
2aaaf5cb9f
commit
cc12ec16fb
|
|
@ -26,7 +26,7 @@ const schema = makeSchema({
|
||||||
],
|
],
|
||||||
contextType: 't.Context',
|
contextType: 't.Context',
|
||||||
},
|
},
|
||||||
prettierConfig: require.resolve('../../../package.json'),
|
prettierConfig: require.resolve('../../../.prettierrc'),
|
||||||
})
|
})
|
||||||
|
|
||||||
const store = createStore()
|
const store = createStore()
|
||||||
|
|
|
||||||
|
|
@ -26,5 +26,5 @@ export const schema = makeSchema({
|
||||||
Date: 'Date',
|
Date: 'Date',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
prettierConfig: require.resolve('../../../package.json'),
|
prettierConfig: require.resolve('../../../.prettierrc'),
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ const schema = makeSchema({
|
||||||
schema: path.join(__dirname, '../githunt-api-schema.graphql'),
|
schema: path.join(__dirname, '../githunt-api-schema.graphql'),
|
||||||
typegen: path.join(__dirname, './githunt-typegen.ts'),
|
typegen: path.join(__dirname, './githunt-typegen.ts'),
|
||||||
},
|
},
|
||||||
prettierConfig: require.resolve('../../../package.json'),
|
prettierConfig: require.resolve('../../../.prettierrc'),
|
||||||
})
|
})
|
||||||
|
|
||||||
const server = new ApolloServer({
|
const server = new ApolloServer({
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,27 @@ type Query {
|
||||||
): BooleanConnection
|
): BooleanConnection
|
||||||
complexQuery(count: Int!): [ComplexObject]
|
complexQuery(count: Int!): [ComplexObject]
|
||||||
dateAsList: [Date]
|
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
|
extended: SomeItem
|
||||||
getNumberOrNull(a: Int!): Int
|
getNumberOrNull(a: Int!): Int
|
||||||
guardedConnection(
|
guardedConnection(
|
||||||
|
|
@ -200,6 +221,10 @@ type Query {
|
||||||
"""
|
"""
|
||||||
first: Int!
|
first: Int!
|
||||||
): UserConnection
|
): UserConnection
|
||||||
|
|
||||||
|
"""
|
||||||
|
A connection with some user nodes
|
||||||
|
"""
|
||||||
usersConnectionNodes(
|
usersConnectionNodes(
|
||||||
"""
|
"""
|
||||||
Returns the elements in the list that come after the specified cursor
|
Returns the elements in the list that come after the specified cursor
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ const schema = makeSchema({
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
prettierConfig: require.resolve('../../../package.json'),
|
prettierConfig: require.resolve('../../../.prettierrc'),
|
||||||
})
|
})
|
||||||
|
|
||||||
const server = new ApolloServer({
|
const server = new ApolloServer({
|
||||||
|
|
|
||||||
|
|
@ -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', {
|
t.connectionField('guardedConnection', {
|
||||||
type: 'Date',
|
type: 'Date',
|
||||||
disableBackwardPagination: true,
|
disableBackwardPagination: true,
|
||||||
|
|
@ -217,6 +226,7 @@ export const Query = objectType({
|
||||||
|
|
||||||
t.connectionField('usersConnectionNodes', {
|
t.connectionField('usersConnectionNodes', {
|
||||||
type: User,
|
type: User,
|
||||||
|
description: 'A connection with some user nodes',
|
||||||
cursorFromNode(node, args, ctx, info, { index, nodes }) {
|
cursorFromNode(node, args, ctx, info, { index, nodes }) {
|
||||||
if (args.last && !args.before) {
|
if (args.last && !args.before) {
|
||||||
const totalCount = USERS_DATA.length
|
const totalCount = USERS_DATA.length
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,7 @@ export interface NexusGenFieldTypes {
|
||||||
booleanConnection: NexusGenRootTypes['BooleanConnection'] | null // BooleanConnection
|
booleanConnection: NexusGenRootTypes['BooleanConnection'] | null // BooleanConnection
|
||||||
complexQuery: Array<NexusGenRootTypes['ComplexObject'] | null> | null // [ComplexObject]
|
complexQuery: Array<NexusGenRootTypes['ComplexObject'] | null> | null // [ComplexObject]
|
||||||
dateAsList: Array<NexusGenScalars['Date'] | null> | null // [Date]
|
dateAsList: Array<NexusGenScalars['Date'] | null> | null // [Date]
|
||||||
|
deprecatedConnection: NexusGenRootTypes['BooleanConnection'] // BooleanConnection!
|
||||||
extended: NexusGenRootTypes['SomeItem'] | null // SomeItem
|
extended: NexusGenRootTypes['SomeItem'] | null // SomeItem
|
||||||
getNumberOrNull: number | null // Int
|
getNumberOrNull: number | null // Int
|
||||||
guardedConnection: NexusGenRootTypes['DateConnection'] | null // DateConnection
|
guardedConnection: NexusGenRootTypes['DateConnection'] | null // DateConnection
|
||||||
|
|
@ -310,6 +311,7 @@ export interface NexusGenFieldTypeNames {
|
||||||
booleanConnection: 'BooleanConnection'
|
booleanConnection: 'BooleanConnection'
|
||||||
complexQuery: 'ComplexObject'
|
complexQuery: 'ComplexObject'
|
||||||
dateAsList: 'Date'
|
dateAsList: 'Date'
|
||||||
|
deprecatedConnection: 'BooleanConnection'
|
||||||
extended: 'SomeItem'
|
extended: 'SomeItem'
|
||||||
getNumberOrNull: 'Int'
|
getNumberOrNull: 'Int'
|
||||||
guardedConnection: 'DateConnection'
|
guardedConnection: 'DateConnection'
|
||||||
|
|
@ -396,6 +398,13 @@ export interface NexusGenArgTypes {
|
||||||
// args
|
// args
|
||||||
count: number // Int!
|
count: number // Int!
|
||||||
}
|
}
|
||||||
|
deprecatedConnection: {
|
||||||
|
// args
|
||||||
|
after?: string | null // String
|
||||||
|
before?: string | null // String
|
||||||
|
first?: number | null // Int
|
||||||
|
last?: number | null // Int
|
||||||
|
}
|
||||||
getNumberOrNull: {
|
getNumberOrNull: {
|
||||||
// args
|
// args
|
||||||
a: number // Int!
|
a: number // Int!
|
||||||
|
|
|
||||||
|
|
@ -31,5 +31,5 @@ export const schema = makeSchema({
|
||||||
],
|
],
|
||||||
contextType: 'swapi.ContextType',
|
contextType: 'swapi.ContextType',
|
||||||
},
|
},
|
||||||
prettierConfig: require.resolve('../../../package.json'),
|
prettierConfig: require.resolve('../../../.prettierrc'),
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ export const schema = makeSchema({
|
||||||
},
|
},
|
||||||
// debug: true,
|
// debug: true,
|
||||||
},
|
},
|
||||||
prettierConfig: require.resolve('../../../package.json'),
|
prettierConfig: require.resolve('../../../.prettierrc'),
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
"clean": "rm -rf dist*",
|
"clean": "rm -rf dist*",
|
||||||
"deploy-site": "yarn && yarn build",
|
"deploy-site": "yarn && yarn build",
|
||||||
"dev": "tsc -p tsconfig.cjs.json -w",
|
"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",
|
"dev:test": "jest --watch",
|
||||||
"examples": "yarn link-examples && yarn gulp run-examples",
|
"examples": "yarn link-examples && yarn gulp run-examples",
|
||||||
"format": "prettier --write 'src/**/*.ts' 'tests/**/*.ts' 'examples/*/src/**.ts'",
|
"format": "prettier --write 'src/**/*.ts' 'tests/**/*.ts' 'examples/*/src/**.ts'",
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,11 @@ gulp.task('link-examples', async () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('api-tsc', () => {
|
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', () => {
|
gulp.task('core-tsc', () => {
|
||||||
runService('yarn', 'tsc -w -p tsconfig.json', {
|
runService('yarn', 'tsc -w -p tsconfig.cjs.json', {
|
||||||
stdio: 'ignore',
|
stdio: 'ignore',
|
||||||
cwd: path.join(__dirname, '..'),
|
cwd: path.join(__dirname, '..'),
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { GraphQLFieldResolver, GraphQLResolveInfo } from 'graphql'
|
import { GraphQLFieldResolver, GraphQLResolveInfo } from 'graphql'
|
||||||
import { ArgsRecord, intArg, stringArg } from '../definitions/args'
|
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 { ObjectDefinitionBlock, objectType } from '../definitions/objectType'
|
||||||
import { AllNexusOutputTypeDefs } from '../definitions/wrapping'
|
import { AllNexusOutputTypeDefs } from '../definitions/wrapping'
|
||||||
import { dynamicOutputMethod } from '../dynamicMethod'
|
import { dynamicOutputMethod } from '../dynamicMethod'
|
||||||
|
|
@ -246,6 +246,7 @@ export type ConnectionFieldConfig<TypeName extends string = any, FieldName exten
|
||||||
nodes?: never
|
nodes?: never
|
||||||
}
|
}
|
||||||
) &
|
) &
|
||||||
|
Pick<CommonFieldConfig, 'deprecation' | 'description' | 'nullable'> &
|
||||||
NexusGenPluginFieldConfig<TypeName, FieldName>
|
NexusGenPluginFieldConfig<TypeName, FieldName>
|
||||||
|
|
||||||
const ForwardPaginateArgs = {
|
const ForwardPaginateArgs = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue