1
+ import { readFile , writeFile } from "node:fs/promises" ;
2
+ import { parseArgs } from "node:util" ;
3
+
1
4
import {
2
5
buildSchema ,
3
6
GraphQLFieldConfig ,
@@ -17,8 +20,6 @@ import {
17
20
validateSchema ,
18
21
} from "graphql" ;
19
22
import type { Maybe } from "graphql/jsutils/Maybe" ;
20
- import { readFile , writeFile } from "node:fs/promises" ;
21
- import { parseArgs } from "node:util" ;
22
23
23
24
export async function main ( toStrict = false ) {
24
25
const {
@@ -83,7 +84,7 @@ export function semanticToStrict(schema: GraphQLSchema) {
83
84
function makeConvertType ( toStrict : boolean ) {
84
85
const cache = new Map < string , GraphQLNamedType > ( ) ;
85
86
86
- function convertFields ( fields : GraphQLFieldConfigMap < any , any > ) {
87
+ function convertFields ( fields : GraphQLFieldConfigMap < unknown , unknown > ) {
87
88
return ( ) => {
88
89
return Object . fromEntries (
89
90
Object . entries ( fields ) . map ( ( [ fieldName , inSpec ] ) => {
@@ -96,7 +97,7 @@ function makeConvertType(toStrict: boolean) {
96
97
} ,
97
98
] ;
98
99
} ) ,
99
- ) as any ;
100
+ ) as GraphQLFieldConfigMap < unknown , unknown > ;
100
101
} ;
101
102
}
102
103
@@ -115,7 +116,9 @@ function makeConvertType(toStrict: boolean) {
115
116
function convertTypes (
116
117
types : readonly GraphQLNamedType [ ] | null | undefined ,
117
118
) : undefined | ( ( ) => readonly GraphQLNamedType [ ] ) {
118
- if ( ! types ) return undefined ;
119
+ if ( ! types ) {
120
+ return undefined ;
121
+ }
119
122
return ( ) => types . map ( ( t ) => convertType ( t ) ) ;
120
123
}
121
124
@@ -127,7 +130,9 @@ function makeConvertType(toStrict: boolean) {
127
130
function convertType ( type : GraphQLNamedType ) : GraphQLNamedType ;
128
131
function convertType ( type : GraphQLType ) : GraphQLType ;
129
132
function convertType ( type : GraphQLType | null | undefined ) {
130
- if ( ! type ) return type ;
133
+ if ( ! type ) {
134
+ return type ;
135
+ }
131
136
if ( type instanceof GraphQLSemanticNonNull ) {
132
137
const unwrapped = convertType ( type . ofType ) ;
133
138
// Here's where we do our thing!
@@ -187,8 +192,8 @@ function makeConvertType(toStrict: boolean) {
187
192
* @see {@url https://www.apollographql.com/docs/kotlin/advanced/nullability/#semanticnonnull }
188
193
*/
189
194
export function applySemanticNonNullDirectiveToFieldConfig (
190
- spec : GraphQLFieldConfig < any , any , any > ,
191
- ) : GraphQLFieldConfig < any , any , any > {
195
+ spec : GraphQLFieldConfig < unknown , unknown , unknown > ,
196
+ ) : GraphQLFieldConfig < unknown , unknown , unknown > {
192
197
const directive = spec . astNode ?. directives ?. find (
193
198
( d ) => d . name . value === "semanticNonNull" ,
194
199
) ;
0 commit comments