Skip to content

Commit 10d9a8d

Browse files
committed
wip
1 parent 29d1518 commit 10d9a8d

File tree

339 files changed

+2460
-13425
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

339 files changed

+2460
-13425
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
2+
using System.Collections.Immutable;
3+
4+
namespace HotChocolate.Types;
5+
6+
public static class DirectiveLocationExtensions
7+
{
8+
private static readonly Dictionary<DirectiveLocation, Language.DirectiveLocation> _typeToLang =
9+
new()
10+
{
11+
{
12+
DirectiveLocation.Query,
13+
Language.DirectiveLocation.Query
14+
},
15+
{
16+
DirectiveLocation.Mutation,
17+
Language.DirectiveLocation.Mutation
18+
},
19+
{
20+
DirectiveLocation.Subscription,
21+
Language.DirectiveLocation.Subscription
22+
},
23+
{
24+
DirectiveLocation.Field,
25+
Language.DirectiveLocation.Field
26+
},
27+
{
28+
DirectiveLocation.FragmentDefinition,
29+
Language.DirectiveLocation.FragmentDefinition
30+
},
31+
{
32+
DirectiveLocation.FragmentSpread,
33+
Language.DirectiveLocation.FragmentSpread
34+
},
35+
{
36+
DirectiveLocation.InlineFragment,
37+
Language.DirectiveLocation.InlineFragment
38+
},
39+
{
40+
DirectiveLocation.VariableDefinition,
41+
Language.DirectiveLocation.VariableDefinition
42+
},
43+
{
44+
DirectiveLocation.Schema,
45+
Language.DirectiveLocation.Schema
46+
},
47+
{
48+
DirectiveLocation.Scalar,
49+
Language.DirectiveLocation.Scalar
50+
},
51+
{
52+
DirectiveLocation.Object,
53+
Language.DirectiveLocation.Object
54+
},
55+
{
56+
DirectiveLocation.FieldDefinition,
57+
Language.DirectiveLocation.FieldDefinition
58+
},
59+
{
60+
DirectiveLocation.ArgumentDefinition,
61+
Language.DirectiveLocation.ArgumentDefinition
62+
},
63+
{
64+
DirectiveLocation.Interface,
65+
Language.DirectiveLocation.Interface
66+
},
67+
{
68+
DirectiveLocation.Union,
69+
Language.DirectiveLocation.Union
70+
},
71+
{
72+
DirectiveLocation.Enum,
73+
Language.DirectiveLocation.Enum
74+
},
75+
{
76+
DirectiveLocation.EnumValue,
77+
Language.DirectiveLocation.EnumValue
78+
},
79+
{
80+
DirectiveLocation.InputObject,
81+
Language.DirectiveLocation.InputObject
82+
},
83+
{
84+
DirectiveLocation.InputFieldDefinition,
85+
Language.DirectiveLocation.InputFieldDefinition
86+
},
87+
};
88+
89+
private static readonly Dictionary<Language.DirectiveLocation, DirectiveLocation> _langToType =
90+
new()
91+
{
92+
{
93+
Language.DirectiveLocation.Query,
94+
DirectiveLocation.Query
95+
},
96+
{
97+
Language.DirectiveLocation.Mutation,
98+
DirectiveLocation.Mutation
99+
},
100+
{
101+
Language.DirectiveLocation.Subscription,
102+
DirectiveLocation.Subscription
103+
},
104+
{
105+
Language.DirectiveLocation.Field,
106+
DirectiveLocation.Field
107+
},
108+
{
109+
Language.DirectiveLocation.FragmentDefinition,
110+
DirectiveLocation.FragmentDefinition
111+
},
112+
{
113+
Language.DirectiveLocation.FragmentSpread,
114+
DirectiveLocation.FragmentSpread
115+
},
116+
{
117+
Language.DirectiveLocation.InlineFragment,
118+
DirectiveLocation.InlineFragment
119+
},
120+
{
121+
Language.DirectiveLocation.VariableDefinition,
122+
DirectiveLocation.VariableDefinition
123+
},
124+
{
125+
Language.DirectiveLocation.Schema,
126+
DirectiveLocation.Schema
127+
},
128+
{
129+
Language.DirectiveLocation.Scalar,
130+
DirectiveLocation.Scalar
131+
},
132+
{
133+
Language.DirectiveLocation.Object,
134+
DirectiveLocation.Object
135+
},
136+
{
137+
Language.DirectiveLocation.FieldDefinition,
138+
DirectiveLocation.FieldDefinition
139+
},
140+
{
141+
Language.DirectiveLocation.ArgumentDefinition,
142+
DirectiveLocation.ArgumentDefinition
143+
},
144+
{
145+
Language.DirectiveLocation.Interface,
146+
DirectiveLocation.Interface
147+
},
148+
{
149+
Language.DirectiveLocation.Union,
150+
DirectiveLocation.Union
151+
},
152+
{
153+
Language.DirectiveLocation.Enum,
154+
DirectiveLocation.Enum
155+
},
156+
{
157+
Language.DirectiveLocation.EnumValue,
158+
DirectiveLocation.EnumValue
159+
},
160+
{
161+
Language.DirectiveLocation.InputObject,
162+
DirectiveLocation.InputObject
163+
},
164+
{
165+
Language.DirectiveLocation.InputFieldDefinition,
166+
DirectiveLocation.InputFieldDefinition
167+
},
168+
};
169+
170+
public static DirectiveLocation ToLocation(this Language.DirectiveLocation location)
171+
=> _langToType[location];
172+
173+
public static IEnumerable<DirectiveLocation> AsEnumerable(
174+
this DirectiveLocation locations)
175+
{
176+
if ((locations & DirectiveLocation.Query) == DirectiveLocation.Query)
177+
{
178+
yield return DirectiveLocation.Query;
179+
}
180+
181+
if ((locations & DirectiveLocation.Mutation) == DirectiveLocation.Mutation)
182+
{
183+
yield return DirectiveLocation.Mutation;
184+
}
185+
186+
if ((locations & DirectiveLocation.Subscription) == DirectiveLocation.Subscription)
187+
{
188+
yield return DirectiveLocation.Subscription;
189+
}
190+
191+
if ((locations & DirectiveLocation.Field) == DirectiveLocation.Field)
192+
{
193+
yield return DirectiveLocation.Field;
194+
}
195+
196+
if ((locations & DirectiveLocation.FragmentDefinition) ==
197+
DirectiveLocation.FragmentDefinition)
198+
{
199+
yield return DirectiveLocation.FragmentDefinition;
200+
}
201+
202+
if ((locations & DirectiveLocation.FragmentSpread) == DirectiveLocation.FragmentSpread)
203+
{
204+
yield return DirectiveLocation.FragmentSpread;
205+
}
206+
207+
if ((locations & DirectiveLocation.InlineFragment) == DirectiveLocation.InlineFragment)
208+
{
209+
yield return DirectiveLocation.InlineFragment;
210+
}
211+
212+
if ((locations & DirectiveLocation.VariableDefinition) ==
213+
DirectiveLocation.VariableDefinition)
214+
{
215+
yield return DirectiveLocation.VariableDefinition;
216+
}
217+
218+
if ((locations & DirectiveLocation.Schema) == DirectiveLocation.Schema)
219+
{
220+
yield return DirectiveLocation.Schema;
221+
}
222+
223+
if ((locations & DirectiveLocation.Scalar) == DirectiveLocation.Scalar)
224+
{
225+
yield return DirectiveLocation.Scalar;
226+
}
227+
228+
if ((locations & DirectiveLocation.Object) == DirectiveLocation.Object)
229+
{
230+
yield return DirectiveLocation.Object;
231+
}
232+
233+
if ((locations & DirectiveLocation.FieldDefinition) ==
234+
DirectiveLocation.FieldDefinition)
235+
{
236+
yield return DirectiveLocation.FieldDefinition;
237+
}
238+
239+
if ((locations & DirectiveLocation.ArgumentDefinition) ==
240+
DirectiveLocation.ArgumentDefinition)
241+
{
242+
yield return DirectiveLocation.ArgumentDefinition;
243+
}
244+
245+
if ((locations & DirectiveLocation.Interface) == DirectiveLocation.Interface)
246+
{
247+
yield return DirectiveLocation.Interface;
248+
}
249+
250+
if ((locations & DirectiveLocation.Union) == DirectiveLocation.Union)
251+
{
252+
yield return DirectiveLocation.Union;
253+
}
254+
255+
if ((locations & DirectiveLocation.Enum) == DirectiveLocation.Enum)
256+
{
257+
yield return DirectiveLocation.Enum;
258+
}
259+
260+
if ((locations & DirectiveLocation.EnumValue) == DirectiveLocation.EnumValue)
261+
{
262+
yield return DirectiveLocation.EnumValue;
263+
}
264+
265+
if ((locations & DirectiveLocation.InputObject) == DirectiveLocation.InputObject)
266+
{
267+
yield return DirectiveLocation.InputObject;
268+
}
269+
270+
if ((locations & DirectiveLocation.InputFieldDefinition) ==
271+
DirectiveLocation.InputFieldDefinition)
272+
{
273+
yield return DirectiveLocation.InputFieldDefinition;
274+
}
275+
}
276+
277+
public static ImmutableArray<Language.NameNode> ToNameNodes(
278+
this DirectiveLocation locations)
279+
=> AsEnumerable(locations)
280+
.Select(t => new Language.NameNode(null, _typeToLang[t].Value))
281+
.ToImmutableArray();
282+
}

src/HotChocolate/Core/src/Types.Abstractions/HotChocolate.Types.Abstractions.csproj

+15
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,19 @@
1515
<ProjectReference Include="..\..\..\Primitives\src\Primitives\HotChocolate.Primitives.csproj" />
1616
</ItemGroup>
1717

18+
<ItemGroup>
19+
<EmbeddedResource Update="Properties\TypesAbstractionResources.resx">
20+
<Generator>ResXFileCodeGenerator</Generator>
21+
<LastGenOutput>TypesAbstractionResources.Designer.cs</LastGenOutput>
22+
</EmbeddedResource>
23+
</ItemGroup>
24+
25+
<ItemGroup>
26+
<Compile Update="Properties\TypesAbstractionResources.Designer.cs">
27+
<DesignTime>True</DesignTime>
28+
<AutoGen>True</AutoGen>
29+
<DependentUpon>TypesAbstractionResources.resx</DependentUpon>
30+
</Compile>
31+
</ItemGroup>
32+
1833
</Project>

src/HotChocolate/Core/src/Types.Abstractions/ISchemaDefinition.cs

+11-7
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,21 @@ namespace HotChocolate;
55

66
public interface ISchemaDefinition : INameProvider, IDescriptionProvider, ISyntaxNodeProvider
77
{
8-
public IObjectTypeDefinition? QueryType { get; }
8+
IObjectTypeDefinition QueryType { get; }
99

10-
public IObjectTypeDefinition? MutationType { get; }
10+
IObjectTypeDefinition? MutationType { get; }
1111

12-
public IObjectTypeDefinition? SubscriptionType { get; }
12+
IObjectTypeDefinition? SubscriptionType { get; }
1313

14-
public IReadOnlyDirectiveCollection Directives { get; }
14+
IReadOnlyDirectiveCollection Directives { get; }
1515

16-
public IReadOnlyTypeDefinitionCollection Types { get; }
16+
IReadOnlyTypeDefinitionCollection Types { get; }
1717

18-
public IReadOnlyDirectiveDefinitionCollection DirectiveDefinitions { get; }
18+
IReadOnlyDirectiveDefinitionCollection DirectiveDefinitions { get; }
1919

20-
public IObjectTypeDefinition GetOperationType(OperationType operationType);
20+
IObjectTypeDefinition GetOperationType(OperationType operationType);
21+
22+
IEnumerable<IObjectTypeDefinition> GetPossibleTypes(ITypeDefinition abstractType);
23+
24+
IEnumerable<INameProvider> GetAllDefinitions();
2125
}

src/HotChocolate/Core/src/Types.Abstractions/Properties/TypesAbstractionResources.Designer.cs

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/HotChocolate/Core/src/Types.Abstractions/Properties/TypesAbstractionResources.resx

+3
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@
1818
<resheader name="writer">
1919
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
2020
</resheader>
21+
<data name="NonNullType_InnerTypeCannotBeNonNull" xml:space="preserve">
22+
<value>The inner type cannot be a non-null type.</value>
23+
</data>
2124
</root>

0 commit comments

Comments
 (0)