File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,23 @@ import (
6
6
7
7
// type Schema interface{}
8
8
9
+ // Result has the response, errors and extensions from the resolved schema
9
10
type Result struct {
10
- Data interface {} `json:"data"`
11
- Errors []gqlerrors.FormattedError `json:"errors,omitempty"`
11
+ Data interface {} `json:"data"`
12
+ Errors []gqlerrors.FormattedError `json:"errors,omitempty"`
13
+ Extensions map [string ]interface {} `json:"extensions,omitempty"`
12
14
}
13
15
16
+ // HasErrors just a simple function to help you decide if the result has errors or not
14
17
func (r * Result ) HasErrors () bool {
15
18
return len (r .Errors ) > 0
16
19
}
20
+
21
+ func (r * Result ) addExtensionResults (p * ExecuteParams ) {
22
+ r .Extensions = map [string ]interface {}{}
23
+ for _ , ext := range p .Schema .extensions {
24
+ if ext .HasResult () {
25
+ r .Extensions [ext .Name ()] = ext .GetResult (p .Context )
26
+ }
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments