-
Notifications
You must be signed in to change notification settings - Fork 3
/
resolvers.go
55 lines (47 loc) · 1.58 KB
/
resolvers.go
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
package resolvers
import (
"context"
"encoding/json"
"reflect"
"github.com/chirino/graphql/schema"
)
type ExecutionContext interface {
GetRoot() interface{}
FireSubscriptionEvent(value reflect.Value, err error)
FireSubscriptionClose()
GetSchema() *schema.Schema
GetContext() context.Context
GetLimiter() *chan byte
HandlePanic(selectionPath []string) error
GetQuery() string
GetDocument() *schema.QueryDocument
GetOperation() *schema.Operation
GetVars() map[string]interface{}
}
type ResolveRequest struct {
Context context.Context
ExecutionContext ExecutionContext
ParentResolve *ResolveRequest
SelectionPath func() []string
ParentType schema.Type
Parent reflect.Value
Field *schema.Field
Args map[string]interface{}
Selection *schema.FieldSelection
}
type Resolution func() (reflect.Value, error)
type Resolver interface {
// Resolve allows you to inspect a ResolveRequest to see if your resolver can resolve it.
// If you can resolve it, return a new Resolution that computes the value of the field.
// If you don't know how to resolve that request, return next.
//
// The next variable hold the Resolution of the previous resolver, this allows your resolver
// to filter it's results. next may be nil if no resolution has been found yet.
Resolve(request *ResolveRequest, next Resolution) Resolution
}
// When RawMessage is the result of a Resolution, for a field, no sub field resolution performed.
type RawMessage json.RawMessage
type ValueWithContext struct {
Value reflect.Value
Context context.Context
}