@@ -83,28 +83,23 @@ public static bool TryGetGraphQLTypeName(
83
83
return false ;
84
84
}
85
85
86
- public static INamedTypeSymbol GetConnectionBaseSymbol ( this GeneratorSyntaxContext context )
86
+ public static INamedTypeSymbol ? GetConnectionBaseSymbol ( this GeneratorSyntaxContext context )
87
87
=> context . SemanticModel . Compilation . GetConnectionBaseSymbol ( ) ;
88
88
89
- public static INamedTypeSymbol GetConnectionBaseSymbol ( this Compilation compilation )
90
- => compilation . GetTypeByMetadataName ( "HotChocolate.Types.Pagination.ConnectionBase`3" )
91
- ?? throw new InvalidOperationException ( "Could not resolve connection base type." ) ;
89
+ public static INamedTypeSymbol ? GetConnectionBaseSymbol ( this Compilation compilation )
90
+ => compilation . GetTypeByMetadataName ( "HotChocolate.Types.Pagination.ConnectionBase`3" ) ;
92
91
93
- public static INamedTypeSymbol GetEdgeInterfaceSymbol ( this Compilation compilation )
94
- => compilation . GetTypeByMetadataName ( "HotChocolate.Types.Pagination.IEdge`1" )
95
- ?? throw new InvalidOperationException ( "Could not resolve edge interface type." ) ;
92
+ public static INamedTypeSymbol ? GetEdgeInterfaceSymbol ( this Compilation compilation )
93
+ => compilation . GetTypeByMetadataName ( "HotChocolate.Types.Pagination.IEdge`1" ) ;
96
94
97
- public static INamedTypeSymbol GetTaskSymbol ( this Compilation compilation )
98
- => compilation . GetTypeByMetadataName ( "System.Threading.Tasks.Task`1" )
99
- ?? throw new InvalidOperationException ( "Could not resolve connection base type." ) ;
95
+ public static INamedTypeSymbol ? GetTaskSymbol ( this Compilation compilation )
96
+ => compilation . GetTypeByMetadataName ( "System.Threading.Tasks.Task`1" ) ;
100
97
101
- public static INamedTypeSymbol GetValueTaskSymbol ( this Compilation compilation )
102
- => compilation . GetTypeByMetadataName ( "System.Threading.Tasks.ValueTask`1" )
103
- ?? throw new InvalidOperationException ( "Could not resolve connection base type." ) ;
98
+ public static INamedTypeSymbol ? GetValueTaskSymbol ( this Compilation compilation )
99
+ => compilation . GetTypeByMetadataName ( "System.Threading.Tasks.ValueTask`1" ) ;
104
100
105
- public static INamedTypeSymbol GetConnectionFlagsSymbol ( this Compilation compilation )
106
- => compilation . GetTypeByMetadataName ( "HotChocolate.Types.Pagination.ConnectionFlags" )
107
- ?? throw new InvalidOperationException ( "Could not resolve connection flags type." ) ;
101
+ public static INamedTypeSymbol ? GetConnectionFlagsSymbol ( this Compilation compilation )
102
+ => compilation . GetTypeByMetadataName ( "HotChocolate.Types.Pagination.ConnectionFlags" ) ;
108
103
109
104
public static bool IsConnectionType ( this GeneratorSyntaxContext context , ITypeSymbol possibleConnectionType )
110
105
=> context . SemanticModel . Compilation . IsConnectionType ( possibleConnectionType ) ;
@@ -174,8 +169,14 @@ public static bool IsConnectionFlagsType(this Compilation compilation, ITypeSymb
174
169
return SymbolEqualityComparer . Default . Equals ( namedType , compilation . GetConnectionFlagsSymbol ( ) ) ;
175
170
}
176
171
177
- private static bool IsDerivedFromGenericBase ( INamedTypeSymbol typeSymbol , INamedTypeSymbol baseTypeSymbol )
172
+ private static bool IsDerivedFromGenericBase ( INamedTypeSymbol ? typeSymbol , INamedTypeSymbol ? baseTypeSymbol )
178
173
{
174
+ // if we are generating only for GreenDonut some base types might not exist.
175
+ if ( baseTypeSymbol is null )
176
+ {
177
+ return false ;
178
+ }
179
+
179
180
var current = typeSymbol ;
180
181
181
182
while ( current is not null )
0 commit comments