11package graphql
22
33type 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
1011}
1112
1213type TypeMap map [string ]Type
@@ -16,24 +17,27 @@ type TypeMap map[string]Type
1617// query, mutation (optional) and subscription (optional). A schema definition is then supplied to the
1718// validator and executor.
1819// 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+ //
2427// Note: If an array of `directives` are provided to GraphQLSchema, that will be
2528// the exact list of directives represented and allowed. If `directives` is not
2629// provided then a default set of the specified directives (e.g. @include and
2730// @skip) will be used. If you wish to provide *additional* directives to these
2831// specified directives, you must explicitly declare them. Example:
2932//
30- // const MyAppSchema = new GraphQLSchema({
31- // ...
32- // directives: specifiedDirectives.concat([ myCustomDirective ]),
33- // })
33+ // const MyAppSchema = new GraphQLSchema({
34+ // ...
35+ // directives: specifiedDirectives.concat([ myCustomDirective ]),
36+ // })
3437type Schema struct {
35- typeMap TypeMap
36- directives []* Directive
38+ typeMap TypeMap
39+ directives []* Directive
40+ appliedDirectives []* AppliedDirective
3741
3842 queryType * Object
3943 mutationType * Object
@@ -76,6 +80,8 @@ func NewSchema(config SchemaConfig) (Schema, error) {
7680 }
7781 }
7882
83+ schema .appliedDirectives = config .AppliedDirectives
84+
7985 // Build type map now to detect any errors within this schema.
8086 typeMap := TypeMap {}
8187 initialTypes := []Type {}
@@ -145,8 +151,8 @@ func NewSchema(config SchemaConfig) (Schema, error) {
145151 return schema , nil
146152}
147153
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..
150156func (gq * Schema ) AddImplementation () error {
151157
152158 // Keep track of all implementations by interface name.
@@ -181,8 +187,8 @@ func (gq *Schema) AddImplementation() error {
181187 return nil
182188}
183189
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
186192func (gq * Schema ) AppendType (objectType Type ) error {
187193 if objectType .Error () != nil {
188194 return objectType .Error ()
@@ -543,3 +549,12 @@ func isTypeSubTypeOf(schema *Schema, maybeSubType Type, superType Type) bool {
543549 // Otherwise, the child type is not a valid subtype of the parent type.
544550 return false
545551}
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