forked from bhoriuchi/graphql-go-tools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresolvers.go
81 lines (65 loc) · 1.8 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package tools
import (
"github.com/graphql-go/graphql"
"github.com/graphql-go/graphql/language/kinds"
)
// Resolver interface to a resolver configuration
type Resolver interface {
getKind() string
}
// ResolverMap a map of resolver configurations.
// Accept generic interfaces and identify types at build
type ResolverMap map[string]interface{}
// internal resolver map
type resolverMap map[string]Resolver
// FieldResolveMap map of field resolve functions
type FieldResolveMap map[string]*FieldResolve
// FieldResolve field resolver
type FieldResolve struct {
Resolve graphql.FieldResolveFn
Subscribe graphql.FieldResolveFn
}
// ObjectResolver config for object resolver map
type ObjectResolver struct {
IsTypeOf graphql.IsTypeOfFn
Fields FieldResolveMap
}
// GetKind gets the kind
func (c *ObjectResolver) getKind() string {
return kinds.ObjectDefinition
}
// ScalarResolver config for a scalar resolve map
type ScalarResolver struct {
Serialize graphql.SerializeFn
ParseValue graphql.ParseValueFn
ParseLiteral graphql.ParseLiteralFn
}
// GetKind gets the kind
func (c *ScalarResolver) getKind() string {
return kinds.ScalarDefinition
}
// InterfaceResolver config for interface resolve
type InterfaceResolver struct {
ResolveType graphql.ResolveTypeFn
Fields FieldResolveMap
}
// GetKind gets the kind
func (c *InterfaceResolver) getKind() string {
return kinds.InterfaceDefinition
}
// UnionResolver config for interface resolve
type UnionResolver struct {
ResolveType graphql.ResolveTypeFn
}
// GetKind gets the kind
func (c *UnionResolver) getKind() string {
return kinds.UnionDefinition
}
// EnumResolver config for enum values
type EnumResolver struct {
Values map[string]interface{}
}
// GetKind gets the kind
func (c *EnumResolver) getKind() string {
return kinds.EnumDefinition
}