@@ -2,12 +2,10 @@ import type { ReadStream } from 'node:fs'
2
2
import * as graphqlTsSchema from '@graphql-ts/schema'
3
3
// @ts -expect-error
4
4
import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
5
- import type { GraphQLFieldExtensions , GraphQLResolveInfo } from 'graphql'
6
5
import { GraphQLError , GraphQLScalarType } from 'graphql'
7
6
import { Decimal as DecimalValue } from 'decimal.js'
8
7
import type { KeystoneContext } from '../context'
9
8
import type { JSONValue } from '../utils'
10
- import { field as fieldd } from './schema-api-with-context'
11
9
12
10
export {
13
11
Boolean ,
@@ -37,79 +35,58 @@ export type {
37
35
NullableInputType ,
38
36
ScalarType ,
39
37
} from '@graphql-ts/schema/api-without-context'
40
- export { bindGraphQLSchemaAPIToContext } from '@graphql-ts/schema'
41
38
export type { BaseSchemaMeta , Extension } from '@graphql-ts/extend'
42
39
export { extend } from '@graphql-ts/extend'
43
- export { fields , interface , interfaceField , object , union } from './schema-api-with-context'
40
+ export { fields , interface , interfaceField , object , union , field } from './schema-api-with-context'
41
+ import { initG as baseInitG } from '@graphql-ts/schema'
42
+ import type { BaseKeystoneTypeInfo } from '../type-info'
43
+ import type { BaseSchemaMeta , Extension } from '@graphql-ts/extend'
44
+ import { extend } from '@graphql-ts/extend'
44
45
45
- // TODO: remove when we use { graphql } from '.keystone'
46
- type SomeTypeThatIsntARecordOfArgs = string
46
+ export function initG < TypeInfo extends BaseKeystoneTypeInfo > ( ) {
47
+ return {
48
+ extend,
49
+ ...baseInitG < KeystoneContext < TypeInfo > > ( ) ,
50
+ }
51
+ }
47
52
48
- type ImpliedResolver <
49
- Args extends { [ Key in keyof Args ] : graphqlTsSchema . Arg < graphqlTsSchema . InputType > } ,
50
- Type extends OutputType < Context > ,
51
- Context extends KeystoneContext < any > ,
52
- > =
53
- | graphqlTsSchema . InferValueFromOutputType < Type >
54
- | ( (
55
- args : graphqlTsSchema . InferValueFromArgs < Args > ,
56
- context : Context ,
57
- info : GraphQLResolveInfo
58
- ) => graphqlTsSchema . InferValueFromOutputType < Type > )
53
+ export declare namespace initG {
54
+ export type Arg = {
55
+ baseSchemaMeta : never
56
+ extension : never
57
+ } & baseInitG . Arg
59
58
60
- export const field : <
61
- Source ,
62
- Type extends OutputType < Context > ,
63
- Resolve extends
64
- | undefined
65
- | ( (
66
- source : Source ,
67
- args : graphqlTsSchema . InferValueFromArgs <
68
- SomeTypeThatIsntARecordOfArgs extends Args ? { } : Args
69
- > ,
70
- context : Context ,
71
- info : GraphQLResolveInfo
72
- ) => graphqlTsSchema . InferValueFromOutputType < Type > ) ,
73
- Context extends KeystoneContext < any > ,
74
- Args extends { [ Key in keyof Args ] : graphqlTsSchema . Arg < graphqlTsSchema . InputType > } = { } ,
75
- > (
76
- field : {
77
- args ?: Args
78
- type : Type
79
- deprecationReason ?: string
80
- description ?: string
81
- extensions ?: Readonly < GraphQLFieldExtensions < Source , unknown > >
82
- } & ( Resolve extends { }
59
+ // the definition of ArgDefaults may change in the future so you should use `ArgDefaults` as the default
60
+ // not `Arg`
61
+ export type ArgDefaults = Arg
62
+
63
+ export type OtherArg = {
64
+ baseSchemaMeta : never
65
+ extension : never
66
+ } & baseInitG . OtherArg
67
+
68
+ export type OtherArgDefaults < FirstArg > = {
69
+ baseSchemaMeta : never
70
+ extension : never
71
+ } & baseInitG . OtherArgDefaults < FirstArg >
72
+
73
+ export type Key = keyof Arg
74
+ export { }
75
+ }
76
+
77
+ export type initG <
78
+ TypeInfo extends BaseKeystoneTypeInfo ,
79
+ K extends initG . Key ,
80
+ FirstArg extends initG . Arg [ K ] ,
81
+ SecondArg extends initG . OtherArg [ K ] = initG . OtherArgDefaults < FirstArg > [ K ] ,
82
+ > = K extends baseInitG . Key
83
+ ? baseInitG < KeystoneContext < TypeInfo > , K , FirstArg , SecondArg >
84
+ : K extends 'baseSchemaMeta' | 'extension'
83
85
? {
84
- resolve : ( (
85
- source : Source ,
86
- args : graphqlTsSchema . InferValueFromArgs <
87
- SomeTypeThatIsntARecordOfArgs extends Args ? { } : Args
88
- > ,
89
- context : Context ,
90
- info : GraphQLResolveInfo
91
- ) => graphqlTsSchema . InferValueFromOutputType < Type > ) &
92
- Resolve
93
- }
94
- : {
95
- resolve ?: ( (
96
- source : Source ,
97
- args : graphqlTsSchema . InferValueFromArgs <
98
- SomeTypeThatIsntARecordOfArgs extends Args ? { } : Args
99
- > ,
100
- context : Context ,
101
- info : GraphQLResolveInfo
102
- ) => graphqlTsSchema . InferValueFromOutputType < Type > ) &
103
- Resolve
104
- } )
105
- ) => Field <
106
- Source ,
107
- Args ,
108
- Type ,
109
- undefined extends Resolve ? ImpliedResolver < Args , Type , Context > : unknown ,
110
- Context
111
- > = fieldd as any
112
- // TODO: remove when we use { graphql } from '.keystone'
86
+ baseSchemaMeta : BaseSchemaMeta
87
+ extension : Extension
88
+ } [ K ]
89
+ : never
113
90
114
91
export const JSON = graphqlTsSchema . g . scalar < JSONValue > (
115
92
new GraphQLScalarType ( {
0 commit comments