Skip to content

Commit 07011c4

Browse files
committed
wip
1 parent 10d9a8d commit 07011c4

File tree

3 files changed

+48
-5
lines changed

3 files changed

+48
-5
lines changed

.build/Helpers.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static class Helpers
2525
Path.Combine("HotChocolate", "Data"),
2626
Path.Combine("HotChocolate", "Marten"),
2727
Path.Combine("HotChocolate", "MongoDb"),
28-
Path.Combine("HotChocolate", "OpenApi"),
28+
// Path.Combine("HotChocolate", "OpenApi"),
2929
Path.Combine("HotChocolate", "Primitives"),
3030
Path.Combine("HotChocolate", "Raven"),
3131
Path.Combine("HotChocolate", "Mutable"),

src/HotChocolate/Fusion-vnext/src/Fusion.Composition/SchemaVisitors/DiscoverLookupsSchemaVisitor.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace HotChocolate.Fusion.SchemaVisitors;
88

99
internal sealed class DiscoverLookupsSchemaVisitor(MutableSchemaDefinition schema)
10-
: SchemaVisitor<DiscoverLookupsContext>
10+
: MutableSchemaDefinitionVisitor<DiscoverLookupsContext>
1111
{
1212
private readonly MultiValueDictionary<string, MutableObjectTypeDefinition>
1313
_implementingTypesByInterfaceName = [];

src/HotChocolate/Mutable/src/Types.Mutable/MutableSchemaDefinition.cs

+46-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ namespace HotChocolate.Types.Mutable;
1010
/// </summary>
1111
public class MutableSchemaDefinition
1212
: INamedTypeSystemMemberDefinition<MutableSchemaDefinition>
13-
, ISchemaDefinition
14-
, IFeatureProvider
13+
, ISchemaDefinition
14+
, IFeatureProvider
1515
{
1616
private readonly List<SchemaCoordinate> _allDefinitionCoordinates = [];
1717
private MutableObjectTypeDefinition? _queryType;
@@ -45,7 +45,8 @@ public MutableObjectTypeDefinition? QueryType
4545
}
4646
}
4747

48-
IObjectTypeDefinition? ISchemaDefinition.QueryType => QueryType;
48+
IObjectTypeDefinition ISchemaDefinition.QueryType
49+
=> QueryType ?? throw new InvalidOperationException("The query type is not defined.");
4950

5051
/// <summary>
5152
/// Gets or sets the mutation type.
@@ -251,6 +252,48 @@ public MutableObjectTypeDefinition GetOperationType(OperationType operationType)
251252
IObjectTypeDefinition ISchemaDefinition.GetOperationType(OperationType operationType)
252253
=> GetOperationType(operationType);
253254

255+
public IEnumerable<MutableObjectTypeDefinition> GetPossibleTypes(ITypeDefinition abstractType)
256+
{
257+
if (abstractType.Kind is not TypeKind.Union and not TypeKind.Interface and not TypeKind.Object)
258+
{
259+
throw new ArgumentException(
260+
"The specified type is not an abstract type.",
261+
nameof(abstractType));
262+
}
263+
264+
if (abstractType is MutableUnionTypeDefinition unionType)
265+
{
266+
foreach (var possibleType in unionType.Types.AsEnumerable())
267+
{
268+
yield return possibleType;
269+
}
270+
271+
yield break;
272+
}
273+
274+
if (abstractType is MutableInterfaceTypeDefinition interfaceType)
275+
{
276+
foreach (var type in Types)
277+
{
278+
if (type is MutableObjectTypeDefinition obj
279+
&& obj.Implements.ContainsName(interfaceType.Name))
280+
{
281+
yield return obj;
282+
}
283+
}
284+
285+
yield break;
286+
}
287+
288+
if (abstractType is MutableObjectTypeDefinition objectType)
289+
{
290+
yield return objectType;
291+
}
292+
}
293+
294+
IEnumerable<IObjectTypeDefinition> ISchemaDefinition.GetPossibleTypes(ITypeDefinition abstractType)
295+
=> GetPossibleTypes(abstractType);
296+
254297
/// <summary>
255298
/// Gets the type and directive definitions that are defined in this schema in insert order.
256299
/// </summary>

0 commit comments

Comments
 (0)