@@ -129,7 +129,7 @@ function structDeclarationForObjectType(generator: CodeGenerator, type: GraphQLO
129
129
( ) => {
130
130
const properties = propertiesFromFields ( generator . context , Object . values ( type . getFields ( ) ) ) ;
131
131
propertyDeclaration ( generator , { fieldName : '__typename' , typeName : `"${ interfaceName } "` } ) ;
132
- properties . forEach ( property => propertyDeclaration ( generator , { ...property , isOptional : true } ) ) ;
132
+ properties . forEach ( property => propertyDeclaration ( generator , { ...property } ) ) ;
133
133
} ,
134
134
) ;
135
135
}
@@ -144,7 +144,7 @@ function structDeclarationForInterfaceType(generator: CodeGenerator, type: Graph
144
144
( ) => {
145
145
const properties = propertiesFromFields ( generator . context , Object . values ( type . getFields ( ) ) ) ;
146
146
propertyDeclaration ( generator , { fieldName : '__typename' , typeName : `"${ interfaceName } "` } ) ;
147
- properties . forEach ( property => propertyDeclaration ( generator , { ...property , isOptional : true } ) ) ;
147
+ properties . forEach ( property => propertyDeclaration ( generator , { ...property } ) ) ;
148
148
} ,
149
149
) ;
150
150
}
@@ -181,7 +181,7 @@ export function interfaceVariablesDeclarationForOperation(
181
181
} ,
182
182
( ) => {
183
183
const properties = propertiesFromFields ( generator . context , variables ) ;
184
- pickedPropertyDeclarations ( generator , properties , true ) ;
184
+ pickedPropertyDeclarations ( generator , properties ) ;
185
185
} ,
186
186
) ;
187
187
}
@@ -361,7 +361,7 @@ export function propertyFromField(
361
361
}
362
362
363
363
if ( isCompositeType ( namedType ) ) {
364
- const typeName = namedType . toString ( ) ;
364
+ let typeName = namedType . toString ( ) ;
365
365
let isArray = false ;
366
366
let isArrayElementNullable = null ;
367
367
if ( isListType ( fieldType ) ) {
@@ -370,6 +370,8 @@ export function propertyFromField(
370
370
} else if ( isNonNullType ( fieldType ) && isListType ( fieldType . ofType ) ) {
371
371
isArray = true ;
372
372
isArrayElementNullable = ! isNonNullType ( fieldType . ofType . ofType ) ;
373
+ } else if ( ! isNonNullType ( fieldType ) ) {
374
+ typeName = typeNameFromGraphQLType ( context , fieldType , null , isNullable ) ;
373
375
}
374
376
375
377
return {
0 commit comments