File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ type SchemaConfig struct {
10
10
Subscription * Object
11
11
Types []Type
12
12
Directives []* Directive
13
+ Extensions []Extension
13
14
}
14
15
15
16
type TypeMap map [string ]Type
@@ -43,6 +44,7 @@ type Schema struct {
43
44
subscriptionType * Object
44
45
implementations map [string ][]* Object
45
46
possibleTypeMap map [string ]map [string ]bool
47
+ extensions []Extension
46
48
}
47
49
48
50
func NewSchema (config SchemaConfig ) (Schema , error ) {
@@ -139,6 +141,11 @@ func NewSchema(config SchemaConfig) (Schema, error) {
139
141
}
140
142
}
141
143
144
+ // Add extensions from config
145
+ if len (config .Extensions ) != 0 {
146
+ schema .extensions = config .Extensions
147
+ }
148
+
142
149
return schema , nil
143
150
}
144
151
@@ -259,6 +266,11 @@ func (gq *Schema) IsPossibleType(abstractType Abstract, possibleType *Object) bo
259
266
return false
260
267
}
261
268
269
+ // AddExtensions can be used to add additional extensions to the schema
270
+ func (gq * Schema ) AddExtensions (e ... Extension ) {
271
+ gq .extensions = append (gq .extensions , e ... )
272
+ }
273
+
262
274
// map-reduce
263
275
func typeMapReducer (schema * Schema , typeMap TypeMap , objectType Type ) (TypeMap , error ) {
264
276
var err error
You can’t perform that action at this time.
0 commit comments