-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathschema.go
40 lines (30 loc) · 851 Bytes
/
schema.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
package bramble
import (
"strings"
"github.com/vektah/gqlparser/v2/ast"
)
var IdFieldName = "id"
const (
nodeRootFieldName = "node"
nodeInterfaceName = "Node"
serviceObjectName = "Service"
serviceRootFieldName = "service"
boundaryDirectiveName = "boundary"
namespaceDirectiveName = "namespace"
queryObjectName = "Query"
mutationObjectName = "Mutation"
subscriptionObjectName = "Subscription"
internalServiceName = "__bramble"
)
func isGraphQLBuiltinName(s string) bool {
return strings.HasPrefix(s, "__")
}
func isIDType(t *ast.Type) bool {
return isNonNullableTypeNamed(t, "ID")
}
func isNonNullableTypeNamed(t *ast.Type, typename string) bool {
return t.Name() == typename && t.NonNull
}
func isNullableTypeNamed(t *ast.Type, typename string) bool {
return t.Name() == typename && !t.NonNull
}