-
-
Notifications
You must be signed in to change notification settings - Fork 723
/
ISchemaBuilder.cs
197 lines (164 loc) · 6.07 KB
/
ISchemaBuilder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
using System;
using System.Collections.Generic;
using HotChocolate.Configuration;
using HotChocolate.Language;
using HotChocolate.Resolvers;
using HotChocolate.Types;
using HotChocolate.Types.Descriptors;
#nullable enable
namespace HotChocolate;
public delegate DocumentNode LoadSchemaDocument(IServiceProvider services);
public delegate IConvention CreateConvention(IServiceProvider services);
/// <summary>
/// The schema builder provides a configuration API to create a GraphQL schema.
/// </summary>
public interface ISchemaBuilder
{
/// <summary>
/// Gets direct access to the schema building context data.
/// </summary>
IDictionary<string, object?> ContextData { get; }
ISchemaBuilder SetSchema(Type type);
ISchemaBuilder SetSchema(ISchema schema);
ISchemaBuilder SetSchema(Action<ISchemaTypeDescriptor> configure);
ISchemaBuilder SetOptions(IReadOnlySchemaOptions options);
ISchemaBuilder ModifyOptions(Action<ISchemaOptions> configure);
ISchemaBuilder Use(FieldMiddleware middleware);
ISchemaBuilder AddDocument(LoadSchemaDocument loadDocument);
/// <summary>
/// Adds a GraphQL type to the schema.
/// </summary>
/// <param name="type">
/// The GraphQL type.
/// </param>
/// <returns>
/// Returns the schema builder to chain in further configuration.
/// </returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="type"/> is <c>null</c>
/// </exception>
ISchemaBuilder AddType(Type type);
/// <summary>
/// Adds a GraphQL type to the schema.
/// </summary>
/// <param name="namedType">
/// The GraphQL type.
/// </param>
/// <returns>
/// Returns the schema builder to chain in further configuration.
/// </returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="namedType"/> is <c>null</c>
/// </exception>
ISchemaBuilder AddType(INamedType namedType);
/// <summary>
/// Adds a GraphQL type extension to the schema.
/// </summary>
/// <param name="typeExtension">
/// The GraphQL type extension.
/// </param>
/// <returns>
/// Returns the schema builder to chain in further configuration.
/// </returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="typeExtension"/> is <c>null</c>
/// </exception>
ISchemaBuilder AddType(INamedTypeExtension typeExtension);
/// <summary>
/// Binds a .NET runtime type to a GraphQL schema type.
/// </summary>
/// <param name="clrType">
/// The .NET runtime type.
/// </param>
/// <param name="schemaType">
/// The GraphQL schema type.
/// </param>
/// <returns></returns>
[Obsolete("Use BindRuntimeType")]
ISchemaBuilder BindClrType(Type clrType, Type schemaType);
/// <summary>
/// Binds a .NET runtime type to a GraphQL schema type.
/// </summary>
/// <param name="runtimeType">
/// The .NET runtime type.
/// </param>
/// <param name="schemaType">
/// The GraphQL schema type.
/// </param>
/// <returns></returns>
ISchemaBuilder BindRuntimeType(Type runtimeType, Type schemaType);
/// <summary>
/// Add a GraphQL root type to the schema.
/// </summary>
/// <param name="rootType">
/// A type representing a GraphQL root type.
/// This type must inherit from <see cref="ObjectType{T}"/> or be a class.
/// </param>
/// <param name="operation">
/// The operation type that <paramref name="rootType"/> represents.
/// </param>
/// <returns>
/// Returns the schema builder to chain in further configuration.
/// </returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="rootType"/> is null.
/// </exception>
/// <exception cref="ArgumentException">
/// - <paramref name="rootType"/> is either not a class or is not inheriting from
/// <see cref="ObjectType{T}"/>.
///
/// - A root type for the specified <paramref name="operation"/> was already set.
/// </exception>
ISchemaBuilder AddRootType(Type rootType, OperationType operation);
/// <summary>
/// Add a GraphQL root type to the schema.
/// </summary>
/// <param name="rootType">
/// An instance of <see cref="ObjectType"/> that represents a root type.
/// </param>
/// <param name="operation">
/// The operation type that <paramref name="rootType"/> represents.
/// </param>
/// <returns>
/// Returns the schema builder to chain in further configuration.
/// </returns>
/// <exception cref="ArgumentNullException">
/// <paramref name="rootType"/> is null.
/// </exception>
/// <exception cref="ArgumentException">
/// A root type for the specified <paramref name="operation"/> was already set.
/// </exception>
ISchemaBuilder AddRootType(ObjectType rootType, OperationType operation);
ISchemaBuilder AddDirectiveType(DirectiveType type);
ISchemaBuilder SetTypeResolver(IsOfTypeFallback isOfType);
ISchemaBuilder AddServices(IServiceProvider services);
ISchemaBuilder SetContextData(string key, object? value);
ISchemaBuilder SetContextData(string key, Func<object?, object?> update);
ISchemaBuilder TryAddTypeInterceptor(Type interceptor);
ISchemaBuilder TryAddTypeInterceptor(ITypeInitializationInterceptor interceptor);
ISchemaBuilder TryAddSchemaInterceptor(Type interceptor);
ISchemaBuilder TryAddSchemaInterceptor(ISchemaInterceptor interceptor);
ISchemaBuilder AddConvention(
Type convention,
CreateConvention factory,
string? scope = null);
ISchemaBuilder TryAddConvention(
Type convention,
CreateConvention factory,
string? scope = null);
/// <summary>
/// Creates a new GraphQL Schema.
/// </summary>
/// <returns>
/// Returns a new GraphQL Schema.
/// </returns>
ISchema Create();
/// <summary>
/// Creates a new GraphQL Schema.
/// </summary>
/// <returns>
/// Returns a new GraphQL Schema.
/// </returns>
ISchema Create(IDescriptorContext context);
IDescriptorContext CreateContext();
}