cubefs

Форк
0
134 строки · 2.5 Кб
1
package ast
2

3
import (
4
	"github.com/graphql-go/graphql/language/kinds"
5
)
6

7
type Selection interface {
8
	GetSelectionSet() *SelectionSet
9
}
10

11
// Ensure that all definition types implements Selection interface
12
var _ Selection = (*Field)(nil)
13
var _ Selection = (*FragmentSpread)(nil)
14
var _ Selection = (*InlineFragment)(nil)
15

16
// Field implements Node, Selection
17
type Field struct {
18
	Kind         string
19
	Loc          *Location
20
	Alias        *Name
21
	Name         *Name
22
	Arguments    []*Argument
23
	Directives   []*Directive
24
	SelectionSet *SelectionSet
25
}
26

27
func NewField(f *Field) *Field {
28
	if f == nil {
29
		f = &Field{}
30
	}
31
	f.Kind = kinds.Field
32
	return f
33
}
34

35
func (f *Field) GetKind() string {
36
	return f.Kind
37
}
38

39
func (f *Field) GetLoc() *Location {
40
	return f.Loc
41
}
42

43
func (f *Field) GetSelectionSet() *SelectionSet {
44
	return f.SelectionSet
45
}
46

47
// FragmentSpread implements Node, Selection
48
type FragmentSpread struct {
49
	Kind       string
50
	Loc        *Location
51
	Name       *Name
52
	Directives []*Directive
53
}
54

55
func NewFragmentSpread(fs *FragmentSpread) *FragmentSpread {
56
	if fs == nil {
57
		fs = &FragmentSpread{}
58
	}
59
	return &FragmentSpread{
60
		Kind:       kinds.FragmentSpread,
61
		Loc:        fs.Loc,
62
		Name:       fs.Name,
63
		Directives: fs.Directives,
64
	}
65
}
66

67
func (fs *FragmentSpread) GetKind() string {
68
	return fs.Kind
69
}
70

71
func (fs *FragmentSpread) GetLoc() *Location {
72
	return fs.Loc
73
}
74

75
func (fs *FragmentSpread) GetSelectionSet() *SelectionSet {
76
	return nil
77
}
78

79
// InlineFragment implements Node, Selection
80
type InlineFragment struct {
81
	Kind          string
82
	Loc           *Location
83
	TypeCondition *Named
84
	Directives    []*Directive
85
	SelectionSet  *SelectionSet
86
}
87

88
func NewInlineFragment(f *InlineFragment) *InlineFragment {
89
	if f == nil {
90
		f = &InlineFragment{}
91
	}
92
	return &InlineFragment{
93
		Kind:          kinds.InlineFragment,
94
		Loc:           f.Loc,
95
		TypeCondition: f.TypeCondition,
96
		Directives:    f.Directives,
97
		SelectionSet:  f.SelectionSet,
98
	}
99
}
100

101
func (f *InlineFragment) GetKind() string {
102
	return f.Kind
103
}
104

105
func (f *InlineFragment) GetLoc() *Location {
106
	return f.Loc
107
}
108

109
func (f *InlineFragment) GetSelectionSet() *SelectionSet {
110
	return f.SelectionSet
111
}
112

113
// SelectionSet implements Node
114
type SelectionSet struct {
115
	Kind       string
116
	Loc        *Location
117
	Selections []Selection
118
}
119

120
func NewSelectionSet(ss *SelectionSet) *SelectionSet {
121
	if ss == nil {
122
		ss = &SelectionSet{}
123
	}
124
	ss.Kind = kinds.SelectionSet
125
	return ss
126
}
127

128
func (ss *SelectionSet) GetKind() string {
129
	return ss.Kind
130
}
131

132
func (ss *SelectionSet) GetLoc() *Location {
133
	return ss.Loc
134
}
135

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.