-
-
Notifications
You must be signed in to change notification settings - Fork 724
/
ISchema.cs
154 lines (138 loc) · 5.37 KB
/
ISchema.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
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using HotChocolate.Language;
using HotChocolate.Types;
using IHasDirectives = HotChocolate.Types.IHasDirectives;
using IHasName = HotChocolate.Types.IHasName;
#nullable enable
namespace HotChocolate
{
/// <summary>
/// A GraphQL Schema defines the capabilities of a GraphQL server. It
/// exposes all available types and directives on the server, as well as
/// the entry points for query, mutation, and subscription operations.
/// </summary>
public interface ISchema
: IHasDirectives
, IHasName
, IHasDescription
, IHasReadOnlyContextData
, ITypeSystemMember
{
/// <summary>
/// Gets the global schema services.
/// </summary>
IServiceProvider? Services { get; }
/// <summary>
/// The type that query operations will be rooted at.
/// </summary>
ObjectType QueryType { get; }
/// <summary>
/// If this server supports mutation, the type that
/// mutation operations will be rooted at.
/// </summary>
ObjectType? MutationType { get; }
/// <summary>
/// If this server support subscription, the type that
/// subscription operations will be rooted at.
/// </summary>
ObjectType? SubscriptionType { get; }
/// <summary>
/// Gets all the schema types.
/// </summary>
IReadOnlyCollection<INamedType> Types { get; }
/// <summary>
/// Gets all the directive types that are supported by this schema.
/// </summary>
IReadOnlyCollection<DirectiveType> DirectiveTypes { get; }
/// <summary>
/// Gets a type by its name and kind.
/// </summary>
/// <typeparam name="T">The expected type kind.</typeparam>
/// <param name="typeName">The name of the type.</param>
/// <returns>The type.</returns>
/// <exception cref="ArgumentException">
/// The specified type does not exist or is not of the
/// specified type kind.
/// </exception>
[return: NotNull]
T GetType<T>(NameString typeName)
where T : INamedType;
/// <summary>
/// Tries to get a type by its name and kind.
/// </summary>
/// <typeparam name="T">The expected type kind.</typeparam>
/// <param name="typeName">The name of the type.</param>
/// <param name="type">The resolved type.</param>
/// <returns>
/// <c>true</c>, if a type with the name exists and is of the specified
/// kind, <c>false</c> otherwise.
/// </returns>
bool TryGetType<T>(NameString typeName, [NotNullWhen(true)]out T type)
where T : INamedType;
/// <summary>
/// Tries to get the .net type representation of a schema type.
/// </summary>
/// <param name="typeName">The name of the type.</param>
/// <param name="runtimeType">The resolved .net type.</param>
/// <returns>
/// <c>true</c>, if a .net type was found that was bound
/// the specified schema type, <c>false</c> otherwise.
/// </returns>
bool TryGetRuntimeType(NameString typeName, [NotNullWhen(true)]out Type? runtimeType);
/// <summary>
/// Gets the possible object types to
/// an abstract type (union type or interface type).
/// </summary>
/// <param name="abstractType">The abstract type.</param>
/// <returns>
/// Returns a collection with all possible object types
/// for the given abstract type.
/// </returns>
IReadOnlyList<ObjectType> GetPossibleTypes(INamedType abstractType);
/// <summary>
/// Gets a directive type by its name.
/// </summary>
/// <param name="directiveName">
/// The directive name.
/// </param>
/// <returns>
/// Returns directive type that was resolved by the given name
/// or <c>null</c> if there is no directive with the specified name.
/// </returns>
/// <exception cref="ArgumentException">
/// The specified directive type does not exist.
/// </exception>
DirectiveType GetDirectiveType(NameString directiveName);
/// <summary>
/// Tries to get a directive type by its name.
/// </summary>
/// <param name="directiveName">
/// The directive name.
/// </param>
/// <param name="directiveType">
/// The directive type that was resolved by the given name
/// or <c>null</c> if there is no directive with the specified name.
/// </param>
/// <returns>
/// <c>true</c>, if a directive type with the specified
/// name exists; otherwise, <c>false</c>.
/// </returns>
bool TryGetDirectiveType(
NameString directiveName,
[NotNullWhen(true)]out DirectiveType? directiveType);
/// <summary>
/// Generates a schema document.
/// </summary>
DocumentNode ToDocument(bool includeSpecScalars = false);
/// <summary>
/// Prints the schema SDL representation.
/// </summary>
string Print();
/// <summary>
/// Prints the schema SDL representation
/// </summary>
string ToString();
}
}