Skip to content

Commit a40afe5

Browse files
committed
feat: extend input type
1 parent 3b8b288 commit a40afe5

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/VirtoCommerce.Xapi.Core/Helpers/GraphTypeExtensionHelper.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ public static Type GetActualComplexType<TGraphType>() where TGraphType : IGraphT
4444
return GetActualComplexTypeRecursive(outerGraphType);
4545
}
4646

47+
public static Type GetActualComplexType(Type graphType)
48+
{
49+
return GetActualComplexTypeRecursive(graphType);
50+
}
51+
4752
private static Type GetActualComplexTypeRecursive(Type outerGraphType)
4853
{
4954
if (outerGraphType.IsGenericType && outerGraphType.GenericTypeArguments.Length > 0)

src/VirtoCommerce.Xapi.Core/Schemas/ExtendableGraphType.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@
1010

1111
namespace VirtoCommerce.Xapi.Core.Schemas
1212
{
13+
public class ExtendableInputObjectGraphType : ExtendableInputObjectGraph<object>
14+
{
15+
}
16+
17+
public class ExtendableInputObjectGraph<TSourceType> : InputObjectGraphType<TSourceType>
18+
{
19+
public override FieldType AddField(FieldType fieldType)
20+
{
21+
fieldType.Type = GraphTypeExtensionHelper.GetActualComplexType(fieldType.Type);
22+
23+
return base.AddField(fieldType);
24+
}
25+
}
26+
1327
public class ExtendableGraphType<TSourceType> : ObjectGraphType<TSourceType>
1428
{
1529
public FieldType ExtendableField<TGraphType>(

0 commit comments

Comments
 (0)