aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/graphql-go/graphql/language/ast/types.go
blob: 27f009979d8139f1f744157f1e1bb95324d5626f (plain) (blame)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package ast

import (
	"github.com/graphql-go/graphql/language/kinds"
)

type Type interface {
	GetKind() string
	GetLoc() *Location
	String() string
}

// Ensure that all value types implements Value interface
var _ Type = (*Named)(nil)
var _ Type = (*List)(nil)
var _ Type = (*NonNull)(nil)

// Named implements Node, Type
type Named struct {
	Kind string
	Loc  *Location
	Name *Name
}

func NewNamed(t *Named) *Named {
	if t == nil {
		t = &Named{}
	}
	return &Named{
		Kind: kinds.Named,
		Loc:  t.Loc,
		Name: t.Name,
	}
}

func (t *Named) GetKind() string {
	return t.Kind
}

func (t *Named) GetLoc() *Location {
	return t.Loc
}

func (t *Named) String() string {
	return t.GetKind()
}

// List implements Node, Type
type List struct {
	Kind string
	Loc  *Location
	Type Type
}

func NewList(t *List) *List {
	if t == nil {
		t = &List{}
	}
	return &List{
		Kind: kinds.List,
		Loc:  t.Loc,
		Type: t.Type,
	}
}

func (t *List) GetKind() string {
	return t.Kind
}

func (t *List) GetLoc() *Location {
	return t.Loc
}

func (t *List) String() string {
	return t.GetKind()
}

// NonNull implements Node, Type
type NonNull struct {
	Kind string
	Loc  *Location
	Type Type
}

func NewNonNull(t *NonNull) *NonNull {
	if t == nil {
		t = &NonNull{}
	}
	return &NonNull{
		Kind: kinds.NonNull,
		Loc:  t.Loc,
		Type: t.Type,
	}
}

func (t *NonNull) GetKind() string {
	return t.Kind
}

func (t *NonNull) GetLoc() *Location {
	return t.Loc
}

func (t *NonNull) String() string {
	return t.GetKind()
}