1
1
package graphql
2
2
3
3
type SchemaConfig struct {
4
- Query * Object
5
- Mutation * Object
6
- Subscription * Object
7
- Types []Type
8
- Directives []* Directive
9
- Extensions []Extension
4
+ Query * Object
5
+ Mutation * Object
6
+ Subscription * Object
7
+ Types []Type
8
+ Directives []* Directive
9
+ AppliedDirectives []* AppliedDirective
10
+ Extensions []Extension
10
11
}
11
12
12
13
type TypeMap map [string ]Type
@@ -16,24 +17,27 @@ type TypeMap map[string]Type
16
17
// query, mutation (optional) and subscription (optional). A schema definition is then supplied to the
17
18
// validator and executor.
18
19
// Example:
19
- // myAppSchema, err := NewSchema(SchemaConfig({
20
- // Query: MyAppQueryRootType,
21
- // Mutation: MyAppMutationRootType,
22
- // Subscription: MyAppSubscriptionRootType,
23
- // });
20
+ //
21
+ // myAppSchema, err := NewSchema(SchemaConfig({
22
+ // Query: MyAppQueryRootType,
23
+ // Mutation: MyAppMutationRootType,
24
+ // Subscription: MyAppSubscriptionRootType,
25
+ // });
26
+ //
24
27
// Note: If an array of `directives` are provided to GraphQLSchema, that will be
25
28
// the exact list of directives represented and allowed. If `directives` is not
26
29
// provided then a default set of the specified directives (e.g. @include and
27
30
// @skip) will be used. If you wish to provide *additional* directives to these
28
31
// specified directives, you must explicitly declare them. Example:
29
32
//
30
- // const MyAppSchema = new GraphQLSchema({
31
- // ...
32
- // directives: specifiedDirectives.concat([ myCustomDirective ]),
33
- // })
33
+ // const MyAppSchema = new GraphQLSchema({
34
+ // ...
35
+ // directives: specifiedDirectives.concat([ myCustomDirective ]),
36
+ // })
34
37
type Schema struct {
35
- typeMap TypeMap
36
- directives []* Directive
38
+ typeMap TypeMap
39
+ directives []* Directive
40
+ appliedDirectives []* AppliedDirective
37
41
38
42
queryType * Object
39
43
mutationType * Object
@@ -76,6 +80,8 @@ func NewSchema(config SchemaConfig) (Schema, error) {
76
80
}
77
81
}
78
82
83
+ schema .appliedDirectives = config .AppliedDirectives
84
+
79
85
// Build type map now to detect any errors within this schema.
80
86
typeMap := TypeMap {}
81
87
initialTypes := []Type {}
@@ -145,8 +151,8 @@ func NewSchema(config SchemaConfig) (Schema, error) {
145
151
return schema , nil
146
152
}
147
153
148
- //Added Check implementation of interfaces at runtime..
149
- //Add Implementations at Runtime..
154
+ // Added Check implementation of interfaces at runtime..
155
+ // Add Implementations at Runtime..
150
156
func (gq * Schema ) AddImplementation () error {
151
157
152
158
// Keep track of all implementations by interface name.
@@ -181,8 +187,8 @@ func (gq *Schema) AddImplementation() error {
181
187
return nil
182
188
}
183
189
184
- //Edited. To check add Types at RunTime..
185
- //Append Runtime schema to typeMap
190
+ // Edited. To check add Types at RunTime..
191
+ // Append Runtime schema to typeMap
186
192
func (gq * Schema ) AppendType (objectType Type ) error {
187
193
if objectType .Error () != nil {
188
194
return objectType .Error ()
@@ -543,3 +549,12 @@ func isTypeSubTypeOf(schema *Schema, maybeSubType Type, superType Type) bool {
543
549
// Otherwise, the child type is not a valid subtype of the parent type.
544
550
return false
545
551
}
552
+
553
+ func (gq * Schema ) AppendAppliedDirective (appliedDirectiveType AppliedDirective ) error {
554
+ gq .appliedDirectives = append (gq .appliedDirectives , & appliedDirectiveType )
555
+ return nil
556
+ }
557
+
558
+ func (gq * Schema ) AppliedDirectives () []* AppliedDirective {
559
+ return gq .appliedDirectives
560
+ }
0 commit comments