@@ -24,6 +24,22 @@ export type CommonOutputFieldConfig<TypeName extends string, FieldName extends s
24
24
args ?: ArgsRecord
25
25
} & NexusGenPluginFieldConfig < TypeName , FieldName >
26
26
27
+ export type CommonInputFieldConfig < TypeName extends string , FieldName extends string > = CommonFieldConfig & {
28
+ /**
29
+ * The default value for the field, if any
30
+ */
31
+ default ?: GetGen3 < 'inputTypes' , TypeName , FieldName >
32
+ } & NexusGenPluginFieldConfig < TypeName , FieldName >
33
+
34
+ /**
35
+ * Deprecated, prefer core.CommonInputFieldConfig
36
+ *
37
+ * TODO(tim): Remove at 1.0
38
+ */
39
+ export interface ScalarInputFieldConfig < T > extends CommonInputFieldConfig < any , any > {
40
+ default ?: T
41
+ }
42
+
27
43
export interface OutputScalarConfig < TypeName extends string , FieldName extends string >
28
44
extends CommonOutputFieldConfig < TypeName , FieldName > {
29
45
/**
@@ -182,15 +198,8 @@ export class OutputDefinitionBlock<TypeName extends string> {
182
198
}
183
199
}
184
200
185
- export interface ScalarInputFieldConfig < T > extends CommonFieldConfig {
186
- /**
187
- * The default value for the field, if any
188
- */
189
- default ?: T
190
- }
191
-
192
201
export interface NexusInputFieldConfig < TypeName extends string , FieldName extends string >
193
- extends ScalarInputFieldConfig < GetGen3 < 'inputTypes' , TypeName , FieldName > > {
202
+ extends CommonInputFieldConfig < TypeName , FieldName > {
194
203
type : AllInputTypes | AllNexusInputTypeDefs < string >
195
204
}
196
205
@@ -222,23 +231,26 @@ export class InputDefinitionBlock<TypeName extends string> {
222
231
return this . _wrapClass ( 'Null' )
223
232
}
224
233
225
- string ( fieldName : string , opts ?: ScalarInputFieldConfig < string > ) {
234
+ string < FieldName extends string > ( fieldName : FieldName , opts ?: CommonInputFieldConfig < TypeName , FieldName > ) {
226
235
this . addScalarField ( fieldName , 'String' , opts )
227
236
}
228
237
229
- int ( fieldName : string , opts ?: ScalarInputFieldConfig < number > ) {
238
+ int < FieldName extends string > ( fieldName : FieldName , opts ?: CommonInputFieldConfig < TypeName , FieldName > ) {
230
239
this . addScalarField ( fieldName , 'Int' , opts )
231
240
}
232
241
233
- boolean ( fieldName : string , opts ?: ScalarInputFieldConfig < boolean > ) {
242
+ boolean < FieldName extends string > (
243
+ fieldName : FieldName ,
244
+ opts ?: CommonInputFieldConfig < TypeName , FieldName >
245
+ ) {
234
246
this . addScalarField ( fieldName , 'Boolean' , opts )
235
247
}
236
248
237
- id ( fieldName : string , opts ?: ScalarInputFieldConfig < string > ) {
249
+ id < FieldName extends string > ( fieldName : FieldName , opts ?: CommonInputFieldConfig < TypeName , FieldName > ) {
238
250
this . addScalarField ( fieldName , 'ID' , opts )
239
251
}
240
252
241
- float ( fieldName : string , opts ?: ScalarInputFieldConfig < number > ) {
253
+ float < FieldName extends string > ( fieldName : FieldName , opts ?: CommonInputFieldConfig < TypeName , FieldName > ) {
242
254
this . addScalarField ( fieldName , 'Float' , opts )
243
255
}
244
256
@@ -266,7 +278,11 @@ export class InputDefinitionBlock<TypeName extends string> {
266
278
return new InputDefinitionBlock ( this . typeBuilder , [ kind ] . concat ( this . wrapping || [ ] ) )
267
279
}
268
280
269
- protected addScalarField ( fieldName : string , typeName : BaseScalars , opts : ScalarInputFieldConfig < any > = { } ) {
281
+ protected addScalarField (
282
+ fieldName : string ,
283
+ typeName : BaseScalars ,
284
+ opts : CommonInputFieldConfig < any , any > = { }
285
+ ) {
270
286
this . typeBuilder . addField ( {
271
287
name : fieldName ,
272
288
type : typeName ,
0 commit comments