-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
48 lines (42 loc) · 1.74 KB
/
doc.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
package ast
import (
"fmt"
"strings"
)
type Document struct {
Operations []*Operation
Fragments []*Fragment
Definitions []Definition
}
func NewDocument() *Document {
return &Document{
Operations: []*Operation{},
Fragments: []*Fragment{},
Definitions: []Definition{},
}
}
const (
// Executable directive locations
QueryDirectiveLocation string = "QUERY"
MutationDirectiveLocation string = "MUTATION"
SubscriptionDirectiveLocation string = "SUBSCRIPTION"
FieldDirectiveLocation string = "FIELD"
FragmentDefinitionDirectiveLocation string = "FRAGMENT_DEFINITION"
FragmentSpreadDirectiveLocation string = "FRAGMENT_SPREAD"
InlineFragmentDirectiveLocation string = "INLINE_FRAGMENT"
// TypeSystem directive locations
SchemaDirectiveLocation string = "SCHEMA"
ScalarDirectiveLocation string = "SCALAR"
ObjectDirectiveLocation string = "OBJECT"
FieldDefinitionDirectiveLocation string = "FIELD_DEFINITION"
ArguentDefinitionDirectiveLocation string = "ARGUMENT_DEFINITION"
InterfaceDirectiveLocation string = "INTERFACE"
UnionDirectiveLocation string = "UNION"
EnumDirectiveLocation string = "ENUM"
EnumValueDirectiveLocation string = "ENUM_VALUE"
InputObjectDirectiveLocation string = "INPUT_OBJECT"
InputFieldDefinitionDirectiveLocation string = "INPUT_FIELD_DEFINITION"
)
func IsValidDirective(d string) bool {
return strings.Contains("QUERY MUTATION SUBSCRIPTION FIELD FRAGMENT_DEFINITION FRAGMENT_SPREAD INLINE_FRAGMENT SCHEMA SCALAR OBJECT FIELD_DEFINITION ARGUMENT_DEFINITION INTERFACE UNION ENUM ENUM_VALUE INPUT_OBJECT INPUT_FIELD_DEFINITION", fmt.Sprintf(" %s ", d))
}