forked from graph-gophers/graphql-go
/
query.go
62 lines (52 loc) · 1.44 KB
/
query.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
package types
import "github.com/tokopedia/graphql-go/errors"
// ExecutableDefinition represents a set of operations or fragments that can be executed
// against a schema.
//
// http://spec.graphql.org/draft/#ExecutableDefinition
type ExecutableDefinition struct {
Operations OperationList
Fragments FragmentList
}
// OperationDefinition represents a GraphQL Operation.
//
// https://spec.graphql.org/draft/#sec-Language.Operations
type OperationDefinition struct {
Type OperationType
Name Ident
Vars ArgumentsDefinition
Selections SelectionSet
Directives DirectiveList
Loc errors.Location
}
type OperationType string
// A Selection is a field requested in a GraphQL operation.
//
// http://spec.graphql.org/draft/#Selection
type Selection interface {
isSelection()
}
// A SelectionSet represents a collection of Selections
//
// http://spec.graphql.org/draft/#sec-Selection-Sets
type SelectionSet []Selection
// Field represents a field used in a query.
type Field struct {
Alias Ident
Name Ident
Arguments ArgumentList
Directives DirectiveList
SelectionSet SelectionSet
SelectionSetLoc errors.Location
}
func (Field) isSelection() {}
type OperationList []*OperationDefinition
// Get returns an OperationDefinition by name or nil if not found.
func (l OperationList) Get(name string) *OperationDefinition {
for _, f := range l {
if f.Name.Name == name {
return f
}
}
return nil
}