Skip to content

Commit cc12ec1

Browse files
authored
fix: add deprecated, description, nullable to connectionField (#578)
1 parent 2aaaf5c commit cc12ec1

File tree

12 files changed

+55
-10
lines changed

12 files changed

+55
-10
lines changed

examples/apollo-fullstack/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const schema = makeSchema({
2626
],
2727
contextType: 't.Context',
2828
},
29-
prettierConfig: require.resolve('../../../package.json'),
29+
prettierConfig: require.resolve('../../../.prettierrc'),
3030
})
3131

3232
const store = createStore()

examples/ghost/src/ghost-schema.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ export const schema = makeSchema({
2626
Date: 'Date',
2727
},
2828
},
29-
prettierConfig: require.resolve('../../../package.json'),
29+
prettierConfig: require.resolve('../../../.prettierrc'),
3030
})

examples/githunt-api/src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const schema = makeSchema({
1010
schema: path.join(__dirname, '../githunt-api-schema.graphql'),
1111
typegen: path.join(__dirname, './githunt-typegen.ts'),
1212
},
13-
prettierConfig: require.resolve('../../../package.json'),
13+
prettierConfig: require.resolve('../../../.prettierrc'),
1414
})
1515

1616
const server = new ApolloServer({

examples/kitchen-sink/kitchen-sink-schema.graphql

+25
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,27 @@ type Query {
146146
): BooleanConnection
147147
complexQuery(count: Int!): [ComplexObject]
148148
dateAsList: [Date]
149+
deprecatedConnection(
150+
"""
151+
Returns the elements in the list that come after the specified cursor
152+
"""
153+
after: String
154+
155+
"""
156+
Returns the elements in the list that come before the specified cursor
157+
"""
158+
before: String
159+
160+
"""
161+
Returns the first n elements from the list.
162+
"""
163+
first: Int
164+
165+
"""
166+
Returns the last n elements from the list.
167+
"""
168+
last: Int
169+
): BooleanConnection! @deprecated(reason: "Dont use this, use booleanConnection instead")
149170
extended: SomeItem
150171
getNumberOrNull(a: Int!): Int
151172
guardedConnection(
@@ -200,6 +221,10 @@ type Query {
200221
"""
201222
first: Int!
202223
): UserConnection
224+
225+
"""
226+
A connection with some user nodes
227+
"""
203228
usersConnectionNodes(
204229
"""
205230
Returns the elements in the list that come after the specified cursor

examples/kitchen-sink/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const schema = makeSchema({
4343
},
4444
}),
4545
],
46-
prettierConfig: require.resolve('../../../package.json'),
46+
prettierConfig: require.resolve('../../../.prettierrc'),
4747
})
4848

4949
const server = new ApolloServer({

examples/kitchen-sink/src/kitchen-sink-definitions.ts

+10
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,15 @@ export const Query = objectType({
204204
},
205205
})
206206

207+
t.connectionField('deprecatedConnection', {
208+
type: 'Boolean',
209+
deprecation: 'Dont use this, use booleanConnection instead',
210+
nullable: false,
211+
nodes() {
212+
return [true]
213+
},
214+
})
215+
207216
t.connectionField('guardedConnection', {
208217
type: 'Date',
209218
disableBackwardPagination: true,
@@ -217,6 +226,7 @@ export const Query = objectType({
217226

218227
t.connectionField('usersConnectionNodes', {
219228
type: User,
229+
description: 'A connection with some user nodes',
220230
cursorFromNode(node, args, ctx, info, { index, nodes }) {
221231
if (args.last && !args.before) {
222232
const totalCount = USERS_DATA.length

examples/kitchen-sink/src/kitchen-sink.gen.ts

+9
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ export interface NexusGenFieldTypes {
201201
booleanConnection: NexusGenRootTypes['BooleanConnection'] | null // BooleanConnection
202202
complexQuery: Array<NexusGenRootTypes['ComplexObject'] | null> | null // [ComplexObject]
203203
dateAsList: Array<NexusGenScalars['Date'] | null> | null // [Date]
204+
deprecatedConnection: NexusGenRootTypes['BooleanConnection'] // BooleanConnection!
204205
extended: NexusGenRootTypes['SomeItem'] | null // SomeItem
205206
getNumberOrNull: number | null // Int
206207
guardedConnection: NexusGenRootTypes['DateConnection'] | null // DateConnection
@@ -310,6 +311,7 @@ export interface NexusGenFieldTypeNames {
310311
booleanConnection: 'BooleanConnection'
311312
complexQuery: 'ComplexObject'
312313
dateAsList: 'Date'
314+
deprecatedConnection: 'BooleanConnection'
313315
extended: 'SomeItem'
314316
getNumberOrNull: 'Int'
315317
guardedConnection: 'DateConnection'
@@ -396,6 +398,13 @@ export interface NexusGenArgTypes {
396398
// args
397399
count: number // Int!
398400
}
401+
deprecatedConnection: {
402+
// args
403+
after?: string | null // String
404+
before?: string | null // String
405+
first?: number | null // Int
406+
last?: number | null // Int
407+
}
399408
getNumberOrNull: {
400409
// args
401410
a: number // Int!

examples/star-wars/src/schema.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ export const schema = makeSchema({
3131
],
3232
contextType: 'swapi.ContextType',
3333
},
34-
prettierConfig: require.resolve('../../../package.json'),
34+
prettierConfig: require.resolve('../../../.prettierrc'),
3535
})

examples/ts-ast-reader/src/schema.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const schema = makeSchema({
2929
},
3030
// debug: true,
3131
},
32-
prettierConfig: require.resolve('../../../package.json'),
32+
prettierConfig: require.resolve('../../../.prettierrc'),
3333
})
3434

3535
/**

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"clean": "rm -rf dist*",
3535
"deploy-site": "yarn && yarn build",
3636
"dev": "tsc -p tsconfig.cjs.json -w",
37-
"dev:examples": "yarn -s link-examples && tsc -w",
37+
"dev:examples": "yarn -s link-examples && yarn dev",
3838
"dev:test": "jest --watch",
3939
"examples": "yarn link-examples && yarn gulp run-examples",
4040
"format": "prettier --write 'src/**/*.ts' 'tests/**/*.ts' 'examples/*/src/**.ts'",

scripts/gulpfile.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ gulp.task('link-examples', async () => {
3434
})
3535

3636
gulp.task('api-tsc', () => {
37-
runService('yarn', 'tsc -w -p api/tsconfig.json', { stdio: 'ignore' })
37+
runService('yarn', 'tsc -w -p api/tsconfig.cjs.json', { stdio: 'ignore' })
3838
})
3939

4040
gulp.task('core-tsc', () => {
41-
runService('yarn', 'tsc -w -p tsconfig.json', {
41+
runService('yarn', 'tsc -w -p tsconfig.cjs.json', {
4242
stdio: 'ignore',
4343
cwd: path.join(__dirname, '..'),
4444
})

src/plugins/connectionPlugin.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { GraphQLFieldResolver, GraphQLResolveInfo } from 'graphql'
22
import { ArgsRecord, intArg, stringArg } from '../definitions/args'
3-
import { FieldOutConfig } from '../definitions/definitionBlocks'
3+
import { CommonFieldConfig, FieldOutConfig } from '../definitions/definitionBlocks'
44
import { ObjectDefinitionBlock, objectType } from '../definitions/objectType'
55
import { AllNexusOutputTypeDefs } from '../definitions/wrapping'
66
import { dynamicOutputMethod } from '../dynamicMethod'
@@ -246,6 +246,7 @@ export type ConnectionFieldConfig<TypeName extends string = any, FieldName exten
246246
nodes?: never
247247
}
248248
) &
249+
Pick<CommonFieldConfig, 'deprecation' | 'description' | 'nullable'> &
249250
NexusGenPluginFieldConfig<TypeName, FieldName>
250251

251252
const ForwardPaginateArgs = {

0 commit comments

Comments
 (0)