Skip to content

Commit 1d32c6f

Browse files
authored
Added OneOf support to Mutable (#8648)
1 parent 0cbb969 commit 1d32c6f

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/HotChocolate/Mutable/src/Types.Mutable/BuiltIns/BuiltIns.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ public static SpecifiedByMutableDirectiveDefinition Create(MutableSchemaDefiniti
105105
}
106106
}
107107

108+
public static class OneOf
109+
{
110+
public const string Name = "oneOf";
111+
112+
public static OneOfMutableDirectiveDefinition Create()
113+
{
114+
return new OneOfMutableDirectiveDefinition();
115+
}
116+
}
117+
108118
public static bool IsBuiltInScalar(string name)
109119
=> name switch
110120
{
@@ -123,6 +133,7 @@ public static bool IsBuiltInDirective(string name)
123133
Skip.Name => true,
124134
Deprecated.Name => true,
125135
SpecifiedBy.Name => true,
136+
OneOf.Name => true,
126137
_ => false
127138
};
128139
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace HotChocolate.Types.Mutable;
2+
3+
public sealed class OneOfMutableDirectiveDefinition : MutableDirectiveDefinition
4+
{
5+
internal OneOfMutableDirectiveDefinition()
6+
: base(BuiltIns.OneOf.Name)
7+
{
8+
IsSpecDirective = true;
9+
Locations = DirectiveLocation.InputObject;
10+
}
11+
}

src/HotChocolate/Mutable/src/Types.Mutable/Serialization/SchemaParser.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,10 @@ private static void BuildDirectiveCollection(
709709
{
710710
directiveType = BuiltIns.Deprecated.Create(schema);
711711
}
712+
else if (directiveNode.Name.Value == BuiltIns.OneOf.Name)
713+
{
714+
directiveType = BuiltIns.OneOf.Create();
715+
}
712716
else if (directiveNode.Name.Value == BuiltIns.SpecifiedBy.Name)
713717
{
714718
directiveType = BuiltIns.SpecifiedBy.Create(schema);

0 commit comments

Comments
 (0)