Skip to content

Commit 330a214

Browse files
add union support (#45) +semver: minor
1 parent 3759302 commit 330a214

16 files changed

+308
-133
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"xmldoc2markdown": {
6-
"version": "4.0.0",
6+
"version": "5.0.0",
77
"commands": [
88
"xmldoc2md"
99
]

docs/api/graphql.query.builder.iquery-1.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public interface IQuery<TSource> : IQuery
1616

1717
`TSource`<br>
1818

19-
Implements [IQuery](./graphql.query.builder.iquery)
19+
Implements [IQuery](./graphql.query.builder.iquery)<br>
20+
Attributes [NullableContextAttribute](./system.runtime.compilerservices.nullablecontextattribute)
2021

2122
## Properties
2223

@@ -183,6 +184,55 @@ The sub-object query building function.
183184
[IQuery&lt;TSource&gt;](./graphql.query.builder.iquery-1)<br>
184185
The query.
185186

187+
### **AddUnion&lt;TUnionType&gt;(String, Func&lt;IQuery&lt;TUnionType&gt;, IQuery&lt;TUnionType&gt;&gt;)**
188+
189+
Adds an union to the query.
190+
191+
```csharp
192+
IQuery<TSource> AddUnion<TUnionType>(string typeName, Func<IQuery<TUnionType>, IQuery<TUnionType>> build)
193+
```
194+
195+
#### Type Parameters
196+
197+
`TUnionType`<br>
198+
The union type.
199+
200+
#### Parameters
201+
202+
`typeName` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
203+
The union type name.
204+
205+
`build` Func&lt;IQuery&lt;TUnionType&gt;, IQuery&lt;TUnionType&gt;&gt;<br>
206+
The union building function.
207+
208+
#### Returns
209+
210+
[IQuery&lt;TSource&gt;](./graphql.query.builder.iquery-1)<br>
211+
The query.
212+
213+
### **AddUnion&lt;TUnionType&gt;(Func&lt;IQuery&lt;TUnionType&gt;, IQuery&lt;TUnionType&gt;&gt;)**
214+
215+
Adds an union to the query.
216+
217+
```csharp
218+
IQuery<TSource> AddUnion<TUnionType>(Func<IQuery<TUnionType>, IQuery<TUnionType>> build)
219+
```
220+
221+
#### Type Parameters
222+
223+
`TUnionType`<br>
224+
The union type.
225+
226+
#### Parameters
227+
228+
`build` Func&lt;IQuery&lt;TUnionType&gt;, IQuery&lt;TUnionType&gt;&gt;<br>
229+
The union building function.
230+
231+
#### Returns
232+
233+
[IQuery&lt;TSource&gt;](./graphql.query.builder.iquery-1)<br>
234+
The query.
235+
186236
### **AddArgument(String, Object)**
187237

188238
Adds a new argument to the query.

docs/api/graphql.query.builder.iquery.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ The query interface.
1212
public interface IQuery
1313
```
1414

15+
Attributes [NullableContextAttribute](./system.runtime.compilerservices.nullablecontextattribute)
16+
1517
## Properties
1618

1719
### **Name**

docs/api/graphql.query.builder.iquerystringbuilder.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ The GraphQL query builder interface.
1212
public interface IQueryStringBuilder
1313
```
1414

15+
Attributes [NullableContextAttribute](./system.runtime.compilerservices.nullablecontextattribute)
16+
1517
## Methods
1618

1719
### **Clear()**

docs/api/graphql.query.builder.query-1.md

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,18 @@ public class Query<TSource> : IQuery`1, IQuery
1717
`TSource`<br>
1818

1919
Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [Query&lt;TSource&gt;](./graphql.query.builder.query-1)<br>
20-
Implements IQuery&lt;TSource&gt;, [IQuery](./graphql.query.builder.iquery)
20+
Implements IQuery&lt;TSource&gt;, [IQuery](./graphql.query.builder.iquery)<br>
21+
Attributes [NullableContextAttribute](./system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](./system.runtime.compilerservices.nullableattribute)
22+
23+
## Fields
24+
25+
### **options**
26+
27+
The query options.
28+
29+
```csharp
30+
protected QueryOptions options;
31+
```
2132

2233
## Properties
2334

@@ -69,6 +80,18 @@ public string AliasName { get; private set; }
6980

7081
[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
7182

83+
### **QueryStringBuilder**
84+
85+
Gets the query string builder.
86+
87+
```csharp
88+
protected IQueryStringBuilder QueryStringBuilder { get; }
89+
```
90+
91+
#### Property Value
92+
93+
[IQueryStringBuilder](./graphql.query.builder.iquerystringbuilder)<br>
94+
7295
## Constructors
7396

7497
### **Query(String)**
@@ -236,6 +259,55 @@ The sub-object query building function.
236259
IQuery&lt;TSource&gt;<br>
237260
The query.
238261

262+
### **AddUnion&lt;TUnionType&gt;(String, Func&lt;IQuery&lt;TUnionType&gt;, IQuery&lt;TUnionType&gt;&gt;)**
263+
264+
Adds an union to the query.
265+
266+
```csharp
267+
public IQuery<TSource> AddUnion<TUnionType>(string typeName, Func<IQuery<TUnionType>, IQuery<TUnionType>> build)
268+
```
269+
270+
#### Type Parameters
271+
272+
`TUnionType`<br>
273+
The union type.
274+
275+
#### Parameters
276+
277+
`typeName` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
278+
The union type name.
279+
280+
`build` Func&lt;IQuery&lt;TUnionType&gt;, IQuery&lt;TUnionType&gt;&gt;<br>
281+
The union building function.
282+
283+
#### Returns
284+
285+
IQuery&lt;TSource&gt;<br>
286+
The query.
287+
288+
### **AddUnion&lt;TUnionType&gt;(Func&lt;IQuery&lt;TUnionType&gt;, IQuery&lt;TUnionType&gt;&gt;)**
289+
290+
Adds an union to the query.
291+
292+
```csharp
293+
public IQuery<TSource> AddUnion<TUnionType>(Func<IQuery<TUnionType>, IQuery<TUnionType>> build)
294+
```
295+
296+
#### Type Parameters
297+
298+
`TUnionType`<br>
299+
The union type.
300+
301+
#### Parameters
302+
303+
`build` Func&lt;IQuery&lt;TUnionType&gt;, IQuery&lt;TUnionType&gt;&gt;<br>
304+
The union building function.
305+
306+
#### Returns
307+
308+
IQuery&lt;TSource&gt;<br>
309+
The query.
310+
239311
### **AddArgument(String, Object)**
240312

241313
Adds a new argument to the query.

docs/api/graphql.query.builder.queryformatters.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

docs/api/graphql.query.builder.querystringbuilder.md

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,18 @@ public class QueryStringBuilder : IQueryStringBuilder
1313
```
1414

1515
Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [QueryStringBuilder](./graphql.query.builder.querystringbuilder)<br>
16-
Implements [IQueryStringBuilder](./graphql.query.builder.iquerystringbuilder)
16+
Implements [IQueryStringBuilder](./graphql.query.builder.iquerystringbuilder)<br>
17+
Attributes [NullableContextAttribute](./system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](./system.runtime.compilerservices.nullableattribute)
18+
19+
## Fields
20+
21+
### **formatter**
22+
23+
The property name formatter.
24+
25+
```csharp
26+
protected Func<PropertyInfo, string> formatter;
27+
```
1728

1829
## Properties
1930

@@ -54,6 +65,28 @@ The property name formatter
5465

5566
## Methods
5667

68+
### **Build&lt;TSource&gt;(IQuery&lt;TSource&gt;)**
69+
70+
Builds the query.
71+
72+
```csharp
73+
public string Build<TSource>(IQuery<TSource> query)
74+
```
75+
76+
#### Type Parameters
77+
78+
`TSource`<br>
79+
80+
#### Parameters
81+
82+
`query` IQuery&lt;TSource&gt;<br>
83+
The query.
84+
85+
#### Returns
86+
87+
[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
88+
The GraphQL query as string, without outer enclosing block.
89+
5790
### **Clear()**
5891

5992
Clears the string builder.
@@ -97,24 +130,6 @@ The formatted query param.
97130
[InvalidDataException](https://docs.microsoft.com/en-us/dotnet/api/system.io.invaliddataexception)<br>
98131
Invalid Object Type in Param List
99132

100-
### **ObjectToDictionary(Object)**
101-
102-
Convert object into dictionary.
103-
104-
```csharp
105-
internal Dictionary<string, object> ObjectToDictionary(object object)
106-
```
107-
108-
#### Parameters
109-
110-
`object` [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object)<br>
111-
The object.
112-
113-
#### Returns
114-
115-
[Dictionary&lt;String, Object&gt;](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2)<br>
116-
The object as dictionary.
117-
118133
### **AddParams&lt;TSource&gt;(IQuery&lt;TSource&gt;)**
119134

120135
Adds query params to the query string.
@@ -154,28 +169,6 @@ The query.
154169
[ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception)<br>
155170
Invalid Object in Field List
156171

157-
### **Build&lt;TSource&gt;(IQuery&lt;TSource&gt;)**
158-
159-
Builds the query.
160-
161-
```csharp
162-
public string Build<TSource>(IQuery<TSource> query)
163-
```
164-
165-
#### Type Parameters
166-
167-
`TSource`<br>
168-
169-
#### Parameters
170-
171-
`query` IQuery&lt;TSource&gt;<br>
172-
The query.
173-
174-
#### Returns
175-
176-
[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)<br>
177-
The GraphQL query as string, without outer enclosing block.
178-
179172
---
180173

181174
[`< Back`](./)

generate-documentation.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
@echo off
22
dotnet tool restore
3-
dotnet build .\src\GraphQL.Query.Builder\GraphQL.Query.Builder.csproj -c Release -o out\
4-
dotnet tool run xmldoc2md .\out\GraphQL.Query.Builder.dll .\docs\api --github-pages --back-button
3+
dotnet build ./src/GraphQL.Query.Builder/GraphQL.Query.Builder.csproj -c Release -o out/
4+
dotnet xmldoc2md out/GraphQL.Query.Builder.dll --output ./docs/api --github-pages --back-button

generate-documentation.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
22

3+
rm -rf ./out/
4+
find ./docs/api -name "*.md" -type f -delete
5+
36
dotnet tool restore
4-
dotnet build src/GraphQL.Query.Builder/GraphQL.Query.Builder.csproj -c Release -o out/
5-
dotnet tool run xmldoc2md out/GraphQL.Query.Builder.dll docs/api --github-pages --back-button
7+
dotnet build ./src/GraphQL.Query.Builder/GraphQL.Query.Builder.csproj -c Release -o out/
8+
dotnet xmldoc2md out/GraphQL.Query.Builder.dll --output ./docs/api --github-pages --back-button

src/GraphQL.Query.Builder/IQueryOf{T}.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,24 @@ IQuery<TSource> AddField<TSubSource>(
5757
Func<IQuery<TSubSource>, IQuery<TSubSource>> build)
5858
where TSubSource : class?;
5959

60+
/// <summary>Adds an union to the query.</summary>
61+
/// <typeparam name="TUnionType">The union type.</typeparam>
62+
/// <param name="typeName">The union type name.</param>
63+
/// <param name="build">The union building function.</param>
64+
/// <returns>The query.</returns>
65+
IQuery<TSource> AddUnion<TUnionType>(
66+
string typeName,
67+
Func<IQuery<TUnionType>, IQuery<TUnionType>> build)
68+
where TUnionType : class?, TSource;
69+
70+
/// <summary>Adds an union to the query.</summary>
71+
/// <typeparam name="TUnionType">The union type.</typeparam>
72+
/// <param name="build">The union building function.</param>
73+
/// <returns>The query.</returns>
74+
IQuery<TSource> AddUnion<TUnionType>(
75+
Func<IQuery<TUnionType>, IQuery<TUnionType>> build)
76+
where TUnionType : class?, TSource;
77+
6078
/// <summary>Adds a new argument to the query.</summary>
6179
/// <param name="key">The argument name.</param>
6280
/// <param name="value">The value.</param>

0 commit comments

Comments
 (0)