graphql-parser 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f43a61f3340211b65a7c51390432b72bace059a1
4
+ data.tar.gz: d0dc0f21c9dd72303191e6b214df9f0d06b42eb2
5
+ SHA512:
6
+ metadata.gz: 2aee8cc6551e5956171f1121386499a634f6493635d79772b1162530bbbb4dd3c9757059238bac3397961a70c3910dbf6889947f2b8a14154b3701bc99072ec7
7
+ data.tar.gz: b5ffd5aa4b1a973fc921fab55fde97d923f04a63e0d9af0d65a92890a3251f42a9ab36c1526c5d08b77e5e0cd59768535f742f3ff60264492b9132899218ef24
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ *.pyc
15
+ mkmf.log
16
+ Makefile
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "libgraphqlparser"]
2
+ path = libgraphqlparser
3
+ url = git@github.com:graphql/libgraphqlparser.git
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in graphql-parser.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,30 @@
1
+ BSD License
2
+
3
+ For graphql-parser software
4
+
5
+ Copyright (c) 2015-present, Shopify, Inc. All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without modification,
8
+ are permitted provided that the following conditions are met:
9
+
10
+ * Redistributions of source code must retain the above copyright notice, this
11
+ list of conditions and the following disclaimer.
12
+
13
+ * Redistributions in binary form must reproduce the above copyright notice,
14
+ this list of conditions and the following disclaimer in the documentation
15
+ and/or other materials provided with the distribution.
16
+
17
+ * Neither the name Shopify nor the names of its contributors may be used to
18
+ endorse or promote products derived from this software without specific
19
+ prior written permission.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
25
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # GraphQL::Parser
2
+
3
+ A small ruby gem wrapping the
4
+ [libgraphqlparser](https://github.com/graphql/libgraphqlparser) C library for
5
+ parsing [GraphQL](http://graphql.org/).
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'graphql-parser'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install graphql-parser
22
+
23
+ ## Usage
24
+
25
+ Parse your graphql string to get an AST:
26
+ ```ruby
27
+ require 'graphql/parser'
28
+ ast = GraphQL::Parser.parse('{ some_graphql_string }') # returns GraphQL::AST
29
+ ```
30
+
31
+ This will raise `GraphQL::ParseError` on malformed input.
32
+
33
+ Implement a visitor:
34
+ ```ruby
35
+ class MyVisitor < GraphQL::Visitor
36
+ def visit_document(node)
37
+ # do something interesting in pre-order
38
+ end
39
+
40
+ def end_visit_document(node)
41
+ # do something interesting in post-order
42
+ end
43
+
44
+ # implement visit methods for all other GraphQL node types or define an
45
+ # appropriate `method_missing` for ones you don't want to handle
46
+ end
47
+ ```
48
+
49
+ And walk the AST:
50
+ ```ruby
51
+ v = MyVisitor.new
52
+ v.accept(ast)
53
+ ```
54
+
55
+ You can return `GraphQL::SKIP_CHILDREN` from a visitor to skip visiting that
56
+ node's children.
57
+
58
+ ## Contributing
59
+
60
+ 1. Fork it ( https://github.com/[my-github-username]/graphql-parser/fork )
61
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
62
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
63
+ 4. Push to the branch (`git push origin my-new-feature`)
64
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/extensiontask'
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new(test: :compile) do |t|
6
+ t.test_files = FileList['test/**/*_test.rb']
7
+ end
8
+
9
+ Rake::ExtensionTask.new 'graphql_parser'
10
+
11
+ desc 'Run tests'
12
+ task default: :test
@@ -0,0 +1,6 @@
1
+ require 'mkmf'
2
+
3
+ dir_config('graphql', '/usr/local/include/graphqlparser', '/usr/local/lib')
4
+ abort 'missing libgraphqlparser' unless have_library 'graphqlparser'
5
+
6
+ create_makefile 'graphql_parser'
@@ -0,0 +1,8 @@
1
+ #include <ruby.h>
2
+
3
+ #include "graphql_ruby.h"
4
+
5
+ void
6
+ Init_graphql_parser(void) {
7
+ init_graphql();
8
+ }
@@ -0,0 +1,906 @@
1
+ /**
2
+ * Copyright (c) 2015, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ */
9
+ /** @generated */
10
+
11
+ #include "c/GraphQLParser.h"
12
+ #include "c/GraphQLAstNode.h"
13
+ #include "c/GraphQLAstVisitor.h"
14
+ #include "c/GraphQLAst.h"
15
+
16
+ #include <ruby.h>
17
+
18
+ #include "graphql_ruby.h"
19
+
20
+ VALUE ast_class, parse_error, skip_children;
21
+
22
+ static struct GraphQLAstVisitorCallbacks cbs;
23
+
24
+ static void free_ast(void *x) {
25
+ graphql_node_free((struct GraphQLAstNode*)x);
26
+ }
27
+
28
+ static const rb_data_type_t ast_type = { "AST", {0, free_ast,}, };
29
+
30
+ static VALUE INT2BOOL(int x) {
31
+ return x ? Qtrue : Qfalse;
32
+ }
33
+
34
+
35
+ const rb_data_type_t definition_type = { "GraphQLAstDefinition", {}, };
36
+ VALUE definition_class;
37
+
38
+ const rb_data_type_t document_type = { "GraphQLAstDocument", {}, };
39
+ VALUE document_class;
40
+ ID visit_document_id;
41
+ ID end_visit_document_id;
42
+ static int visit_document(const struct GraphQLAstDocument *document, void *user_data) {
43
+ VALUE parent = (VALUE)user_data;
44
+ VALUE param = TypedData_Wrap_Struct(document_class, &document_type, (void*)document);
45
+ return rb_funcall(parent, visit_document_id, 1, param) != skip_children;
46
+ }
47
+
48
+ static void end_visit_document(const struct GraphQLAstDocument *document, void *user_data) {
49
+ VALUE parent = (VALUE)user_data;
50
+ VALUE param = TypedData_Wrap_Struct(document_class, &document_type, (void*)document);
51
+ rb_funcall(parent, end_visit_document_id, 1, param);
52
+ }
53
+
54
+ static VALUE document_get_definitions_size(VALUE self) {
55
+ struct GraphQLAstDocument *node;
56
+ TypedData_Get_Struct(self, struct GraphQLAstDocument, &document_type, node);
57
+ return INT2FIX(GraphQLAstDocument_get_definitions_size(node));
58
+ }
59
+
60
+
61
+ const rb_data_type_t operation_definition_type = { "GraphQLAstOperationDefinition", {}, };
62
+ VALUE operation_definition_class;
63
+ ID visit_operation_definition_id;
64
+ ID end_visit_operation_definition_id;
65
+ static int visit_operation_definition(const struct GraphQLAstOperationDefinition *operation_definition, void *user_data) {
66
+ VALUE parent = (VALUE)user_data;
67
+ VALUE param = TypedData_Wrap_Struct(operation_definition_class, &operation_definition_type, (void*)operation_definition);
68
+ return rb_funcall(parent, visit_operation_definition_id, 1, param) != skip_children;
69
+ }
70
+
71
+ static void end_visit_operation_definition(const struct GraphQLAstOperationDefinition *operation_definition, void *user_data) {
72
+ VALUE parent = (VALUE)user_data;
73
+ VALUE param = TypedData_Wrap_Struct(operation_definition_class, &operation_definition_type, (void*)operation_definition);
74
+ rb_funcall(parent, end_visit_operation_definition_id, 1, param);
75
+ }
76
+
77
+ static VALUE operation_definition_get_operation(VALUE self) {
78
+ struct GraphQLAstOperationDefinition *node;
79
+ TypedData_Get_Struct(self, struct GraphQLAstOperationDefinition, &operation_definition_type, node);
80
+ return rb_str_new_cstr(GraphQLAstOperationDefinition_get_operation(node));
81
+ }
82
+
83
+ static VALUE operation_definition_get_name(VALUE self) {
84
+ struct GraphQLAstOperationDefinition *node;
85
+ TypedData_Get_Struct(self, struct GraphQLAstOperationDefinition, &operation_definition_type, node);
86
+ if (GraphQLAstOperationDefinition_get_name(node) == NULL) return Qnil;
87
+ return TypedData_Wrap_Struct(name_class, &name_type, (void*)GraphQLAstOperationDefinition_get_name(node));
88
+ }
89
+
90
+ static VALUE operation_definition_get_variable_definitions_size(VALUE self) {
91
+ struct GraphQLAstOperationDefinition *node;
92
+ TypedData_Get_Struct(self, struct GraphQLAstOperationDefinition, &operation_definition_type, node);
93
+ return INT2FIX(GraphQLAstOperationDefinition_get_variable_definitions_size(node));
94
+ }
95
+
96
+ static VALUE operation_definition_get_directives_size(VALUE self) {
97
+ struct GraphQLAstOperationDefinition *node;
98
+ TypedData_Get_Struct(self, struct GraphQLAstOperationDefinition, &operation_definition_type, node);
99
+ return INT2FIX(GraphQLAstOperationDefinition_get_directives_size(node));
100
+ }
101
+
102
+ static VALUE operation_definition_get_selection_set(VALUE self) {
103
+ struct GraphQLAstOperationDefinition *node;
104
+ TypedData_Get_Struct(self, struct GraphQLAstOperationDefinition, &operation_definition_type, node);
105
+ return TypedData_Wrap_Struct(selection_set_class, &selection_set_type, (void*)GraphQLAstOperationDefinition_get_selection_set(node));
106
+ }
107
+
108
+
109
+ const rb_data_type_t variable_definition_type = { "GraphQLAstVariableDefinition", {}, };
110
+ VALUE variable_definition_class;
111
+ ID visit_variable_definition_id;
112
+ ID end_visit_variable_definition_id;
113
+ static int visit_variable_definition(const struct GraphQLAstVariableDefinition *variable_definition, void *user_data) {
114
+ VALUE parent = (VALUE)user_data;
115
+ VALUE param = TypedData_Wrap_Struct(variable_definition_class, &variable_definition_type, (void*)variable_definition);
116
+ return rb_funcall(parent, visit_variable_definition_id, 1, param) != skip_children;
117
+ }
118
+
119
+ static void end_visit_variable_definition(const struct GraphQLAstVariableDefinition *variable_definition, void *user_data) {
120
+ VALUE parent = (VALUE)user_data;
121
+ VALUE param = TypedData_Wrap_Struct(variable_definition_class, &variable_definition_type, (void*)variable_definition);
122
+ rb_funcall(parent, end_visit_variable_definition_id, 1, param);
123
+ }
124
+
125
+ static VALUE variable_definition_get_variable(VALUE self) {
126
+ struct GraphQLAstVariableDefinition *node;
127
+ TypedData_Get_Struct(self, struct GraphQLAstVariableDefinition, &variable_definition_type, node);
128
+ return TypedData_Wrap_Struct(variable_class, &variable_type, (void*)GraphQLAstVariableDefinition_get_variable(node));
129
+ }
130
+
131
+ static VALUE variable_definition_get_type(VALUE self) {
132
+ struct GraphQLAstVariableDefinition *node;
133
+ TypedData_Get_Struct(self, struct GraphQLAstVariableDefinition, &variable_definition_type, node);
134
+ return TypedData_Wrap_Struct(type_class, &type_type, (void*)GraphQLAstVariableDefinition_get_type(node));
135
+ }
136
+
137
+ static VALUE variable_definition_get_default_value(VALUE self) {
138
+ struct GraphQLAstVariableDefinition *node;
139
+ TypedData_Get_Struct(self, struct GraphQLAstVariableDefinition, &variable_definition_type, node);
140
+ if (GraphQLAstVariableDefinition_get_default_value(node) == NULL) return Qnil;
141
+ return TypedData_Wrap_Struct(value_class, &value_type, (void*)GraphQLAstVariableDefinition_get_default_value(node));
142
+ }
143
+
144
+
145
+ const rb_data_type_t selection_set_type = { "GraphQLAstSelectionSet", {}, };
146
+ VALUE selection_set_class;
147
+ ID visit_selection_set_id;
148
+ ID end_visit_selection_set_id;
149
+ static int visit_selection_set(const struct GraphQLAstSelectionSet *selection_set, void *user_data) {
150
+ VALUE parent = (VALUE)user_data;
151
+ VALUE param = TypedData_Wrap_Struct(selection_set_class, &selection_set_type, (void*)selection_set);
152
+ return rb_funcall(parent, visit_selection_set_id, 1, param) != skip_children;
153
+ }
154
+
155
+ static void end_visit_selection_set(const struct GraphQLAstSelectionSet *selection_set, void *user_data) {
156
+ VALUE parent = (VALUE)user_data;
157
+ VALUE param = TypedData_Wrap_Struct(selection_set_class, &selection_set_type, (void*)selection_set);
158
+ rb_funcall(parent, end_visit_selection_set_id, 1, param);
159
+ }
160
+
161
+ static VALUE selection_set_get_selections_size(VALUE self) {
162
+ struct GraphQLAstSelectionSet *node;
163
+ TypedData_Get_Struct(self, struct GraphQLAstSelectionSet, &selection_set_type, node);
164
+ return INT2FIX(GraphQLAstSelectionSet_get_selections_size(node));
165
+ }
166
+
167
+
168
+ const rb_data_type_t selection_type = { "GraphQLAstSelection", {}, };
169
+ VALUE selection_class;
170
+
171
+ const rb_data_type_t field_type = { "GraphQLAstField", {}, };
172
+ VALUE field_class;
173
+ ID visit_field_id;
174
+ ID end_visit_field_id;
175
+ static int visit_field(const struct GraphQLAstField *field, void *user_data) {
176
+ VALUE parent = (VALUE)user_data;
177
+ VALUE param = TypedData_Wrap_Struct(field_class, &field_type, (void*)field);
178
+ return rb_funcall(parent, visit_field_id, 1, param) != skip_children;
179
+ }
180
+
181
+ static void end_visit_field(const struct GraphQLAstField *field, void *user_data) {
182
+ VALUE parent = (VALUE)user_data;
183
+ VALUE param = TypedData_Wrap_Struct(field_class, &field_type, (void*)field);
184
+ rb_funcall(parent, end_visit_field_id, 1, param);
185
+ }
186
+
187
+ static VALUE field_get_alias(VALUE self) {
188
+ struct GraphQLAstField *node;
189
+ TypedData_Get_Struct(self, struct GraphQLAstField, &field_type, node);
190
+ if (GraphQLAstField_get_alias(node) == NULL) return Qnil;
191
+ return TypedData_Wrap_Struct(name_class, &name_type, (void*)GraphQLAstField_get_alias(node));
192
+ }
193
+
194
+ static VALUE field_get_name(VALUE self) {
195
+ struct GraphQLAstField *node;
196
+ TypedData_Get_Struct(self, struct GraphQLAstField, &field_type, node);
197
+ return TypedData_Wrap_Struct(name_class, &name_type, (void*)GraphQLAstField_get_name(node));
198
+ }
199
+
200
+ static VALUE field_get_arguments_size(VALUE self) {
201
+ struct GraphQLAstField *node;
202
+ TypedData_Get_Struct(self, struct GraphQLAstField, &field_type, node);
203
+ return INT2FIX(GraphQLAstField_get_arguments_size(node));
204
+ }
205
+
206
+ static VALUE field_get_directives_size(VALUE self) {
207
+ struct GraphQLAstField *node;
208
+ TypedData_Get_Struct(self, struct GraphQLAstField, &field_type, node);
209
+ return INT2FIX(GraphQLAstField_get_directives_size(node));
210
+ }
211
+
212
+ static VALUE field_get_selection_set(VALUE self) {
213
+ struct GraphQLAstField *node;
214
+ TypedData_Get_Struct(self, struct GraphQLAstField, &field_type, node);
215
+ if (GraphQLAstField_get_selection_set(node) == NULL) return Qnil;
216
+ return TypedData_Wrap_Struct(selection_set_class, &selection_set_type, (void*)GraphQLAstField_get_selection_set(node));
217
+ }
218
+
219
+
220
+ const rb_data_type_t argument_type = { "GraphQLAstArgument", {}, };
221
+ VALUE argument_class;
222
+ ID visit_argument_id;
223
+ ID end_visit_argument_id;
224
+ static int visit_argument(const struct GraphQLAstArgument *argument, void *user_data) {
225
+ VALUE parent = (VALUE)user_data;
226
+ VALUE param = TypedData_Wrap_Struct(argument_class, &argument_type, (void*)argument);
227
+ return rb_funcall(parent, visit_argument_id, 1, param) != skip_children;
228
+ }
229
+
230
+ static void end_visit_argument(const struct GraphQLAstArgument *argument, void *user_data) {
231
+ VALUE parent = (VALUE)user_data;
232
+ VALUE param = TypedData_Wrap_Struct(argument_class, &argument_type, (void*)argument);
233
+ rb_funcall(parent, end_visit_argument_id, 1, param);
234
+ }
235
+
236
+ static VALUE argument_get_name(VALUE self) {
237
+ struct GraphQLAstArgument *node;
238
+ TypedData_Get_Struct(self, struct GraphQLAstArgument, &argument_type, node);
239
+ return TypedData_Wrap_Struct(name_class, &name_type, (void*)GraphQLAstArgument_get_name(node));
240
+ }
241
+
242
+ static VALUE argument_get_value(VALUE self) {
243
+ struct GraphQLAstArgument *node;
244
+ TypedData_Get_Struct(self, struct GraphQLAstArgument, &argument_type, node);
245
+ return TypedData_Wrap_Struct(value_class, &value_type, (void*)GraphQLAstArgument_get_value(node));
246
+ }
247
+
248
+
249
+ const rb_data_type_t fragment_spread_type = { "GraphQLAstFragmentSpread", {}, };
250
+ VALUE fragment_spread_class;
251
+ ID visit_fragment_spread_id;
252
+ ID end_visit_fragment_spread_id;
253
+ static int visit_fragment_spread(const struct GraphQLAstFragmentSpread *fragment_spread, void *user_data) {
254
+ VALUE parent = (VALUE)user_data;
255
+ VALUE param = TypedData_Wrap_Struct(fragment_spread_class, &fragment_spread_type, (void*)fragment_spread);
256
+ return rb_funcall(parent, visit_fragment_spread_id, 1, param) != skip_children;
257
+ }
258
+
259
+ static void end_visit_fragment_spread(const struct GraphQLAstFragmentSpread *fragment_spread, void *user_data) {
260
+ VALUE parent = (VALUE)user_data;
261
+ VALUE param = TypedData_Wrap_Struct(fragment_spread_class, &fragment_spread_type, (void*)fragment_spread);
262
+ rb_funcall(parent, end_visit_fragment_spread_id, 1, param);
263
+ }
264
+
265
+ static VALUE fragment_spread_get_name(VALUE self) {
266
+ struct GraphQLAstFragmentSpread *node;
267
+ TypedData_Get_Struct(self, struct GraphQLAstFragmentSpread, &fragment_spread_type, node);
268
+ return TypedData_Wrap_Struct(name_class, &name_type, (void*)GraphQLAstFragmentSpread_get_name(node));
269
+ }
270
+
271
+ static VALUE fragment_spread_get_directives_size(VALUE self) {
272
+ struct GraphQLAstFragmentSpread *node;
273
+ TypedData_Get_Struct(self, struct GraphQLAstFragmentSpread, &fragment_spread_type, node);
274
+ return INT2FIX(GraphQLAstFragmentSpread_get_directives_size(node));
275
+ }
276
+
277
+
278
+ const rb_data_type_t inline_fragment_type = { "GraphQLAstInlineFragment", {}, };
279
+ VALUE inline_fragment_class;
280
+ ID visit_inline_fragment_id;
281
+ ID end_visit_inline_fragment_id;
282
+ static int visit_inline_fragment(const struct GraphQLAstInlineFragment *inline_fragment, void *user_data) {
283
+ VALUE parent = (VALUE)user_data;
284
+ VALUE param = TypedData_Wrap_Struct(inline_fragment_class, &inline_fragment_type, (void*)inline_fragment);
285
+ return rb_funcall(parent, visit_inline_fragment_id, 1, param) != skip_children;
286
+ }
287
+
288
+ static void end_visit_inline_fragment(const struct GraphQLAstInlineFragment *inline_fragment, void *user_data) {
289
+ VALUE parent = (VALUE)user_data;
290
+ VALUE param = TypedData_Wrap_Struct(inline_fragment_class, &inline_fragment_type, (void*)inline_fragment);
291
+ rb_funcall(parent, end_visit_inline_fragment_id, 1, param);
292
+ }
293
+
294
+ static VALUE inline_fragment_get_type_condition(VALUE self) {
295
+ struct GraphQLAstInlineFragment *node;
296
+ TypedData_Get_Struct(self, struct GraphQLAstInlineFragment, &inline_fragment_type, node);
297
+ return TypedData_Wrap_Struct(named_type_class, &named_type_type, (void*)GraphQLAstInlineFragment_get_type_condition(node));
298
+ }
299
+
300
+ static VALUE inline_fragment_get_directives_size(VALUE self) {
301
+ struct GraphQLAstInlineFragment *node;
302
+ TypedData_Get_Struct(self, struct GraphQLAstInlineFragment, &inline_fragment_type, node);
303
+ return INT2FIX(GraphQLAstInlineFragment_get_directives_size(node));
304
+ }
305
+
306
+ static VALUE inline_fragment_get_selection_set(VALUE self) {
307
+ struct GraphQLAstInlineFragment *node;
308
+ TypedData_Get_Struct(self, struct GraphQLAstInlineFragment, &inline_fragment_type, node);
309
+ return TypedData_Wrap_Struct(selection_set_class, &selection_set_type, (void*)GraphQLAstInlineFragment_get_selection_set(node));
310
+ }
311
+
312
+
313
+ const rb_data_type_t fragment_definition_type = { "GraphQLAstFragmentDefinition", {}, };
314
+ VALUE fragment_definition_class;
315
+ ID visit_fragment_definition_id;
316
+ ID end_visit_fragment_definition_id;
317
+ static int visit_fragment_definition(const struct GraphQLAstFragmentDefinition *fragment_definition, void *user_data) {
318
+ VALUE parent = (VALUE)user_data;
319
+ VALUE param = TypedData_Wrap_Struct(fragment_definition_class, &fragment_definition_type, (void*)fragment_definition);
320
+ return rb_funcall(parent, visit_fragment_definition_id, 1, param) != skip_children;
321
+ }
322
+
323
+ static void end_visit_fragment_definition(const struct GraphQLAstFragmentDefinition *fragment_definition, void *user_data) {
324
+ VALUE parent = (VALUE)user_data;
325
+ VALUE param = TypedData_Wrap_Struct(fragment_definition_class, &fragment_definition_type, (void*)fragment_definition);
326
+ rb_funcall(parent, end_visit_fragment_definition_id, 1, param);
327
+ }
328
+
329
+ static VALUE fragment_definition_get_name(VALUE self) {
330
+ struct GraphQLAstFragmentDefinition *node;
331
+ TypedData_Get_Struct(self, struct GraphQLAstFragmentDefinition, &fragment_definition_type, node);
332
+ return TypedData_Wrap_Struct(name_class, &name_type, (void*)GraphQLAstFragmentDefinition_get_name(node));
333
+ }
334
+
335
+ static VALUE fragment_definition_get_type_condition(VALUE self) {
336
+ struct GraphQLAstFragmentDefinition *node;
337
+ TypedData_Get_Struct(self, struct GraphQLAstFragmentDefinition, &fragment_definition_type, node);
338
+ return TypedData_Wrap_Struct(named_type_class, &named_type_type, (void*)GraphQLAstFragmentDefinition_get_type_condition(node));
339
+ }
340
+
341
+ static VALUE fragment_definition_get_directives_size(VALUE self) {
342
+ struct GraphQLAstFragmentDefinition *node;
343
+ TypedData_Get_Struct(self, struct GraphQLAstFragmentDefinition, &fragment_definition_type, node);
344
+ return INT2FIX(GraphQLAstFragmentDefinition_get_directives_size(node));
345
+ }
346
+
347
+ static VALUE fragment_definition_get_selection_set(VALUE self) {
348
+ struct GraphQLAstFragmentDefinition *node;
349
+ TypedData_Get_Struct(self, struct GraphQLAstFragmentDefinition, &fragment_definition_type, node);
350
+ return TypedData_Wrap_Struct(selection_set_class, &selection_set_type, (void*)GraphQLAstFragmentDefinition_get_selection_set(node));
351
+ }
352
+
353
+
354
+ const rb_data_type_t value_type = { "GraphQLAstValue", {}, };
355
+ VALUE value_class;
356
+
357
+ const rb_data_type_t variable_type = { "GraphQLAstVariable", {}, };
358
+ VALUE variable_class;
359
+ ID visit_variable_id;
360
+ ID end_visit_variable_id;
361
+ static int visit_variable(const struct GraphQLAstVariable *variable, void *user_data) {
362
+ VALUE parent = (VALUE)user_data;
363
+ VALUE param = TypedData_Wrap_Struct(variable_class, &variable_type, (void*)variable);
364
+ return rb_funcall(parent, visit_variable_id, 1, param) != skip_children;
365
+ }
366
+
367
+ static void end_visit_variable(const struct GraphQLAstVariable *variable, void *user_data) {
368
+ VALUE parent = (VALUE)user_data;
369
+ VALUE param = TypedData_Wrap_Struct(variable_class, &variable_type, (void*)variable);
370
+ rb_funcall(parent, end_visit_variable_id, 1, param);
371
+ }
372
+
373
+ static VALUE variable_get_name(VALUE self) {
374
+ struct GraphQLAstVariable *node;
375
+ TypedData_Get_Struct(self, struct GraphQLAstVariable, &variable_type, node);
376
+ return TypedData_Wrap_Struct(name_class, &name_type, (void*)GraphQLAstVariable_get_name(node));
377
+ }
378
+
379
+
380
+ const rb_data_type_t int_value_type = { "GraphQLAstIntValue", {}, };
381
+ VALUE int_value_class;
382
+ ID visit_int_value_id;
383
+ ID end_visit_int_value_id;
384
+ static int visit_int_value(const struct GraphQLAstIntValue *int_value, void *user_data) {
385
+ VALUE parent = (VALUE)user_data;
386
+ VALUE param = TypedData_Wrap_Struct(int_value_class, &int_value_type, (void*)int_value);
387
+ return rb_funcall(parent, visit_int_value_id, 1, param) != skip_children;
388
+ }
389
+
390
+ static void end_visit_int_value(const struct GraphQLAstIntValue *int_value, void *user_data) {
391
+ VALUE parent = (VALUE)user_data;
392
+ VALUE param = TypedData_Wrap_Struct(int_value_class, &int_value_type, (void*)int_value);
393
+ rb_funcall(parent, end_visit_int_value_id, 1, param);
394
+ }
395
+
396
+ static VALUE int_value_get_value(VALUE self) {
397
+ struct GraphQLAstIntValue *node;
398
+ TypedData_Get_Struct(self, struct GraphQLAstIntValue, &int_value_type, node);
399
+ return rb_str_new_cstr(GraphQLAstIntValue_get_value(node));
400
+ }
401
+
402
+
403
+ const rb_data_type_t float_value_type = { "GraphQLAstFloatValue", {}, };
404
+ VALUE float_value_class;
405
+ ID visit_float_value_id;
406
+ ID end_visit_float_value_id;
407
+ static int visit_float_value(const struct GraphQLAstFloatValue *float_value, void *user_data) {
408
+ VALUE parent = (VALUE)user_data;
409
+ VALUE param = TypedData_Wrap_Struct(float_value_class, &float_value_type, (void*)float_value);
410
+ return rb_funcall(parent, visit_float_value_id, 1, param) != skip_children;
411
+ }
412
+
413
+ static void end_visit_float_value(const struct GraphQLAstFloatValue *float_value, void *user_data) {
414
+ VALUE parent = (VALUE)user_data;
415
+ VALUE param = TypedData_Wrap_Struct(float_value_class, &float_value_type, (void*)float_value);
416
+ rb_funcall(parent, end_visit_float_value_id, 1, param);
417
+ }
418
+
419
+ static VALUE float_value_get_value(VALUE self) {
420
+ struct GraphQLAstFloatValue *node;
421
+ TypedData_Get_Struct(self, struct GraphQLAstFloatValue, &float_value_type, node);
422
+ return rb_str_new_cstr(GraphQLAstFloatValue_get_value(node));
423
+ }
424
+
425
+
426
+ const rb_data_type_t string_value_type = { "GraphQLAstStringValue", {}, };
427
+ VALUE string_value_class;
428
+ ID visit_string_value_id;
429
+ ID end_visit_string_value_id;
430
+ static int visit_string_value(const struct GraphQLAstStringValue *string_value, void *user_data) {
431
+ VALUE parent = (VALUE)user_data;
432
+ VALUE param = TypedData_Wrap_Struct(string_value_class, &string_value_type, (void*)string_value);
433
+ return rb_funcall(parent, visit_string_value_id, 1, param) != skip_children;
434
+ }
435
+
436
+ static void end_visit_string_value(const struct GraphQLAstStringValue *string_value, void *user_data) {
437
+ VALUE parent = (VALUE)user_data;
438
+ VALUE param = TypedData_Wrap_Struct(string_value_class, &string_value_type, (void*)string_value);
439
+ rb_funcall(parent, end_visit_string_value_id, 1, param);
440
+ }
441
+
442
+ static VALUE string_value_get_value(VALUE self) {
443
+ struct GraphQLAstStringValue *node;
444
+ TypedData_Get_Struct(self, struct GraphQLAstStringValue, &string_value_type, node);
445
+ return rb_str_new_cstr(GraphQLAstStringValue_get_value(node));
446
+ }
447
+
448
+
449
+ const rb_data_type_t boolean_value_type = { "GraphQLAstBooleanValue", {}, };
450
+ VALUE boolean_value_class;
451
+ ID visit_boolean_value_id;
452
+ ID end_visit_boolean_value_id;
453
+ static int visit_boolean_value(const struct GraphQLAstBooleanValue *boolean_value, void *user_data) {
454
+ VALUE parent = (VALUE)user_data;
455
+ VALUE param = TypedData_Wrap_Struct(boolean_value_class, &boolean_value_type, (void*)boolean_value);
456
+ return rb_funcall(parent, visit_boolean_value_id, 1, param) != skip_children;
457
+ }
458
+
459
+ static void end_visit_boolean_value(const struct GraphQLAstBooleanValue *boolean_value, void *user_data) {
460
+ VALUE parent = (VALUE)user_data;
461
+ VALUE param = TypedData_Wrap_Struct(boolean_value_class, &boolean_value_type, (void*)boolean_value);
462
+ rb_funcall(parent, end_visit_boolean_value_id, 1, param);
463
+ }
464
+
465
+ static VALUE boolean_value_get_value(VALUE self) {
466
+ struct GraphQLAstBooleanValue *node;
467
+ TypedData_Get_Struct(self, struct GraphQLAstBooleanValue, &boolean_value_type, node);
468
+ return INT2BOOL(GraphQLAstBooleanValue_get_value(node));
469
+ }
470
+
471
+
472
+ const rb_data_type_t enum_value_type = { "GraphQLAstEnumValue", {}, };
473
+ VALUE enum_value_class;
474
+ ID visit_enum_value_id;
475
+ ID end_visit_enum_value_id;
476
+ static int visit_enum_value(const struct GraphQLAstEnumValue *enum_value, void *user_data) {
477
+ VALUE parent = (VALUE)user_data;
478
+ VALUE param = TypedData_Wrap_Struct(enum_value_class, &enum_value_type, (void*)enum_value);
479
+ return rb_funcall(parent, visit_enum_value_id, 1, param) != skip_children;
480
+ }
481
+
482
+ static void end_visit_enum_value(const struct GraphQLAstEnumValue *enum_value, void *user_data) {
483
+ VALUE parent = (VALUE)user_data;
484
+ VALUE param = TypedData_Wrap_Struct(enum_value_class, &enum_value_type, (void*)enum_value);
485
+ rb_funcall(parent, end_visit_enum_value_id, 1, param);
486
+ }
487
+
488
+ static VALUE enum_value_get_value(VALUE self) {
489
+ struct GraphQLAstEnumValue *node;
490
+ TypedData_Get_Struct(self, struct GraphQLAstEnumValue, &enum_value_type, node);
491
+ return rb_str_new_cstr(GraphQLAstEnumValue_get_value(node));
492
+ }
493
+
494
+
495
+ const rb_data_type_t array_value_type = { "GraphQLAstArrayValue", {}, };
496
+ VALUE array_value_class;
497
+ ID visit_array_value_id;
498
+ ID end_visit_array_value_id;
499
+ static int visit_array_value(const struct GraphQLAstArrayValue *array_value, void *user_data) {
500
+ VALUE parent = (VALUE)user_data;
501
+ VALUE param = TypedData_Wrap_Struct(array_value_class, &array_value_type, (void*)array_value);
502
+ return rb_funcall(parent, visit_array_value_id, 1, param) != skip_children;
503
+ }
504
+
505
+ static void end_visit_array_value(const struct GraphQLAstArrayValue *array_value, void *user_data) {
506
+ VALUE parent = (VALUE)user_data;
507
+ VALUE param = TypedData_Wrap_Struct(array_value_class, &array_value_type, (void*)array_value);
508
+ rb_funcall(parent, end_visit_array_value_id, 1, param);
509
+ }
510
+
511
+ static VALUE array_value_get_values_size(VALUE self) {
512
+ struct GraphQLAstArrayValue *node;
513
+ TypedData_Get_Struct(self, struct GraphQLAstArrayValue, &array_value_type, node);
514
+ return INT2FIX(GraphQLAstArrayValue_get_values_size(node));
515
+ }
516
+
517
+
518
+ const rb_data_type_t object_value_type = { "GraphQLAstObjectValue", {}, };
519
+ VALUE object_value_class;
520
+ ID visit_object_value_id;
521
+ ID end_visit_object_value_id;
522
+ static int visit_object_value(const struct GraphQLAstObjectValue *object_value, void *user_data) {
523
+ VALUE parent = (VALUE)user_data;
524
+ VALUE param = TypedData_Wrap_Struct(object_value_class, &object_value_type, (void*)object_value);
525
+ return rb_funcall(parent, visit_object_value_id, 1, param) != skip_children;
526
+ }
527
+
528
+ static void end_visit_object_value(const struct GraphQLAstObjectValue *object_value, void *user_data) {
529
+ VALUE parent = (VALUE)user_data;
530
+ VALUE param = TypedData_Wrap_Struct(object_value_class, &object_value_type, (void*)object_value);
531
+ rb_funcall(parent, end_visit_object_value_id, 1, param);
532
+ }
533
+
534
+ static VALUE object_value_get_fields_size(VALUE self) {
535
+ struct GraphQLAstObjectValue *node;
536
+ TypedData_Get_Struct(self, struct GraphQLAstObjectValue, &object_value_type, node);
537
+ return INT2FIX(GraphQLAstObjectValue_get_fields_size(node));
538
+ }
539
+
540
+
541
+ const rb_data_type_t object_field_type = { "GraphQLAstObjectField", {}, };
542
+ VALUE object_field_class;
543
+ ID visit_object_field_id;
544
+ ID end_visit_object_field_id;
545
+ static int visit_object_field(const struct GraphQLAstObjectField *object_field, void *user_data) {
546
+ VALUE parent = (VALUE)user_data;
547
+ VALUE param = TypedData_Wrap_Struct(object_field_class, &object_field_type, (void*)object_field);
548
+ return rb_funcall(parent, visit_object_field_id, 1, param) != skip_children;
549
+ }
550
+
551
+ static void end_visit_object_field(const struct GraphQLAstObjectField *object_field, void *user_data) {
552
+ VALUE parent = (VALUE)user_data;
553
+ VALUE param = TypedData_Wrap_Struct(object_field_class, &object_field_type, (void*)object_field);
554
+ rb_funcall(parent, end_visit_object_field_id, 1, param);
555
+ }
556
+
557
+ static VALUE object_field_get_name(VALUE self) {
558
+ struct GraphQLAstObjectField *node;
559
+ TypedData_Get_Struct(self, struct GraphQLAstObjectField, &object_field_type, node);
560
+ return TypedData_Wrap_Struct(name_class, &name_type, (void*)GraphQLAstObjectField_get_name(node));
561
+ }
562
+
563
+ static VALUE object_field_get_value(VALUE self) {
564
+ struct GraphQLAstObjectField *node;
565
+ TypedData_Get_Struct(self, struct GraphQLAstObjectField, &object_field_type, node);
566
+ return TypedData_Wrap_Struct(value_class, &value_type, (void*)GraphQLAstObjectField_get_value(node));
567
+ }
568
+
569
+
570
+ const rb_data_type_t directive_type = { "GraphQLAstDirective", {}, };
571
+ VALUE directive_class;
572
+ ID visit_directive_id;
573
+ ID end_visit_directive_id;
574
+ static int visit_directive(const struct GraphQLAstDirective *directive, void *user_data) {
575
+ VALUE parent = (VALUE)user_data;
576
+ VALUE param = TypedData_Wrap_Struct(directive_class, &directive_type, (void*)directive);
577
+ return rb_funcall(parent, visit_directive_id, 1, param) != skip_children;
578
+ }
579
+
580
+ static void end_visit_directive(const struct GraphQLAstDirective *directive, void *user_data) {
581
+ VALUE parent = (VALUE)user_data;
582
+ VALUE param = TypedData_Wrap_Struct(directive_class, &directive_type, (void*)directive);
583
+ rb_funcall(parent, end_visit_directive_id, 1, param);
584
+ }
585
+
586
+ static VALUE directive_get_name(VALUE self) {
587
+ struct GraphQLAstDirective *node;
588
+ TypedData_Get_Struct(self, struct GraphQLAstDirective, &directive_type, node);
589
+ return TypedData_Wrap_Struct(name_class, &name_type, (void*)GraphQLAstDirective_get_name(node));
590
+ }
591
+
592
+ static VALUE directive_get_arguments_size(VALUE self) {
593
+ struct GraphQLAstDirective *node;
594
+ TypedData_Get_Struct(self, struct GraphQLAstDirective, &directive_type, node);
595
+ return INT2FIX(GraphQLAstDirective_get_arguments_size(node));
596
+ }
597
+
598
+
599
+ const rb_data_type_t type_type = { "GraphQLAstType", {}, };
600
+ VALUE type_class;
601
+
602
+ const rb_data_type_t named_type_type = { "GraphQLAstNamedType", {}, };
603
+ VALUE named_type_class;
604
+ ID visit_named_type_id;
605
+ ID end_visit_named_type_id;
606
+ static int visit_named_type(const struct GraphQLAstNamedType *named_type, void *user_data) {
607
+ VALUE parent = (VALUE)user_data;
608
+ VALUE param = TypedData_Wrap_Struct(named_type_class, &named_type_type, (void*)named_type);
609
+ return rb_funcall(parent, visit_named_type_id, 1, param) != skip_children;
610
+ }
611
+
612
+ static void end_visit_named_type(const struct GraphQLAstNamedType *named_type, void *user_data) {
613
+ VALUE parent = (VALUE)user_data;
614
+ VALUE param = TypedData_Wrap_Struct(named_type_class, &named_type_type, (void*)named_type);
615
+ rb_funcall(parent, end_visit_named_type_id, 1, param);
616
+ }
617
+
618
+ static VALUE named_type_get_name(VALUE self) {
619
+ struct GraphQLAstNamedType *node;
620
+ TypedData_Get_Struct(self, struct GraphQLAstNamedType, &named_type_type, node);
621
+ return TypedData_Wrap_Struct(name_class, &name_type, (void*)GraphQLAstNamedType_get_name(node));
622
+ }
623
+
624
+
625
+ const rb_data_type_t list_type_type = { "GraphQLAstListType", {}, };
626
+ VALUE list_type_class;
627
+ ID visit_list_type_id;
628
+ ID end_visit_list_type_id;
629
+ static int visit_list_type(const struct GraphQLAstListType *list_type, void *user_data) {
630
+ VALUE parent = (VALUE)user_data;
631
+ VALUE param = TypedData_Wrap_Struct(list_type_class, &list_type_type, (void*)list_type);
632
+ return rb_funcall(parent, visit_list_type_id, 1, param) != skip_children;
633
+ }
634
+
635
+ static void end_visit_list_type(const struct GraphQLAstListType *list_type, void *user_data) {
636
+ VALUE parent = (VALUE)user_data;
637
+ VALUE param = TypedData_Wrap_Struct(list_type_class, &list_type_type, (void*)list_type);
638
+ rb_funcall(parent, end_visit_list_type_id, 1, param);
639
+ }
640
+
641
+ static VALUE list_type_get_type(VALUE self) {
642
+ struct GraphQLAstListType *node;
643
+ TypedData_Get_Struct(self, struct GraphQLAstListType, &list_type_type, node);
644
+ return TypedData_Wrap_Struct(type_class, &type_type, (void*)GraphQLAstListType_get_type(node));
645
+ }
646
+
647
+
648
+ const rb_data_type_t non_null_type_type = { "GraphQLAstNonNullType", {}, };
649
+ VALUE non_null_type_class;
650
+ ID visit_non_null_type_id;
651
+ ID end_visit_non_null_type_id;
652
+ static int visit_non_null_type(const struct GraphQLAstNonNullType *non_null_type, void *user_data) {
653
+ VALUE parent = (VALUE)user_data;
654
+ VALUE param = TypedData_Wrap_Struct(non_null_type_class, &non_null_type_type, (void*)non_null_type);
655
+ return rb_funcall(parent, visit_non_null_type_id, 1, param) != skip_children;
656
+ }
657
+
658
+ static void end_visit_non_null_type(const struct GraphQLAstNonNullType *non_null_type, void *user_data) {
659
+ VALUE parent = (VALUE)user_data;
660
+ VALUE param = TypedData_Wrap_Struct(non_null_type_class, &non_null_type_type, (void*)non_null_type);
661
+ rb_funcall(parent, end_visit_non_null_type_id, 1, param);
662
+ }
663
+
664
+ static VALUE non_null_type_get_type(VALUE self) {
665
+ struct GraphQLAstNonNullType *node;
666
+ TypedData_Get_Struct(self, struct GraphQLAstNonNullType, &non_null_type_type, node);
667
+ return TypedData_Wrap_Struct(type_class, &type_type, (void*)GraphQLAstNonNullType_get_type(node));
668
+ }
669
+
670
+
671
+ const rb_data_type_t name_type = { "GraphQLAstName", {}, };
672
+ VALUE name_class;
673
+ ID visit_name_id;
674
+ ID end_visit_name_id;
675
+ static int visit_name(const struct GraphQLAstName *name, void *user_data) {
676
+ VALUE parent = (VALUE)user_data;
677
+ VALUE param = TypedData_Wrap_Struct(name_class, &name_type, (void*)name);
678
+ return rb_funcall(parent, visit_name_id, 1, param) != skip_children;
679
+ }
680
+
681
+ static void end_visit_name(const struct GraphQLAstName *name, void *user_data) {
682
+ VALUE parent = (VALUE)user_data;
683
+ VALUE param = TypedData_Wrap_Struct(name_class, &name_type, (void*)name);
684
+ rb_funcall(parent, end_visit_name_id, 1, param);
685
+ }
686
+
687
+ static VALUE name_get_value(VALUE self) {
688
+ struct GraphQLAstName *node;
689
+ TypedData_Get_Struct(self, struct GraphQLAstName, &name_type, node);
690
+ return rb_str_new_cstr(GraphQLAstName_get_value(node));
691
+ }
692
+
693
+
694
+
695
+ static VALUE parse(VALUE self, VALUE text) {
696
+ char *input;
697
+ struct GraphQLAstNode *n;
698
+ const char *error;
699
+
700
+ input = StringValueCStr(text);
701
+
702
+ n = graphql_parse_string(input, &error);
703
+
704
+ if (n == NULL) {
705
+ VALUE exc = rb_exc_new_cstr(parse_error, error);
706
+ graphql_error_free(error);
707
+ rb_exc_raise(exc);
708
+ return Qnil;
709
+ }
710
+
711
+ return TypedData_Wrap_Struct(ast_class, &ast_type, n);
712
+ }
713
+
714
+ static VALUE accept(VALUE self, VALUE ast) {
715
+ struct GraphQLAstNode *n;
716
+
717
+ TypedData_Get_Struct(ast, struct GraphQLAstNode, &ast_type, n);
718
+
719
+ graphql_node_visit(n, &cbs, (void*)self);
720
+
721
+ return Qnil;
722
+ }
723
+
724
+ void init_graphql(void) {
725
+ VALUE module, parser, visitor, node_class;
726
+
727
+ module = rb_define_module("GraphQL");
728
+
729
+ parser = rb_define_module_under(module, "Parser");
730
+ rb_define_module_function(parser, "parse", parse, 1);
731
+
732
+ visitor = rb_define_class_under(module, "Visitor", rb_cObject);
733
+ rb_define_method(visitor, "accept", accept, 1);
734
+
735
+ parse_error = rb_define_class_under(module, "ParseError", rb_eArgError);
736
+
737
+ ast_class = rb_define_class_under(module, "AST", rb_cObject);
738
+
739
+ node_class = rb_define_class_under(module, "Node", rb_cObject);
740
+
741
+ skip_children = rb_class_new_instance(0, NULL, rb_cObject);
742
+ rb_define_const(module, "SKIP_CHILDREN", skip_children);
743
+
744
+
745
+ document_class = rb_define_class_under(module, "Document", node_class);
746
+ operation_definition_class = rb_define_class_under(module, "OperationDefinition", node_class);
747
+ variable_definition_class = rb_define_class_under(module, "VariableDefinition", node_class);
748
+ selection_set_class = rb_define_class_under(module, "SelectionSet", node_class);
749
+ field_class = rb_define_class_under(module, "Field", node_class);
750
+ argument_class = rb_define_class_under(module, "Argument", node_class);
751
+ fragment_spread_class = rb_define_class_under(module, "FragmentSpread", node_class);
752
+ inline_fragment_class = rb_define_class_under(module, "InlineFragment", node_class);
753
+ fragment_definition_class = rb_define_class_under(module, "FragmentDefinition", node_class);
754
+ variable_class = rb_define_class_under(module, "Variable", node_class);
755
+ int_value_class = rb_define_class_under(module, "IntValue", node_class);
756
+ float_value_class = rb_define_class_under(module, "FloatValue", node_class);
757
+ string_value_class = rb_define_class_under(module, "StringValue", node_class);
758
+ boolean_value_class = rb_define_class_under(module, "BooleanValue", node_class);
759
+ enum_value_class = rb_define_class_under(module, "EnumValue", node_class);
760
+ array_value_class = rb_define_class_under(module, "ArrayValue", node_class);
761
+ object_value_class = rb_define_class_under(module, "ObjectValue", node_class);
762
+ object_field_class = rb_define_class_under(module, "ObjectField", node_class);
763
+ directive_class = rb_define_class_under(module, "Directive", node_class);
764
+ named_type_class = rb_define_class_under(module, "NamedType", node_class);
765
+ list_type_class = rb_define_class_under(module, "ListType", node_class);
766
+ non_null_type_class = rb_define_class_under(module, "NonNullType", node_class);
767
+ name_class = rb_define_class_under(module, "Name", node_class);
768
+
769
+ rb_define_method(document_class, "definitions_size", document_get_definitions_size, 0);
770
+ rb_define_method(operation_definition_class, "operation", operation_definition_get_operation, 0);
771
+ rb_define_method(operation_definition_class, "name", operation_definition_get_name, 0);
772
+ rb_define_method(operation_definition_class, "variable_definitions_size", operation_definition_get_variable_definitions_size, 0);
773
+ rb_define_method(operation_definition_class, "directives_size", operation_definition_get_directives_size, 0);
774
+ rb_define_method(operation_definition_class, "selection_set", operation_definition_get_selection_set, 0);
775
+ rb_define_method(variable_definition_class, "variable", variable_definition_get_variable, 0);
776
+ rb_define_method(variable_definition_class, "type", variable_definition_get_type, 0);
777
+ rb_define_method(variable_definition_class, "default_value", variable_definition_get_default_value, 0);
778
+ rb_define_method(selection_set_class, "selections_size", selection_set_get_selections_size, 0);
779
+ rb_define_method(field_class, "alias", field_get_alias, 0);
780
+ rb_define_method(field_class, "name", field_get_name, 0);
781
+ rb_define_method(field_class, "arguments_size", field_get_arguments_size, 0);
782
+ rb_define_method(field_class, "directives_size", field_get_directives_size, 0);
783
+ rb_define_method(field_class, "selection_set", field_get_selection_set, 0);
784
+ rb_define_method(argument_class, "name", argument_get_name, 0);
785
+ rb_define_method(argument_class, "value", argument_get_value, 0);
786
+ rb_define_method(fragment_spread_class, "name", fragment_spread_get_name, 0);
787
+ rb_define_method(fragment_spread_class, "directives_size", fragment_spread_get_directives_size, 0);
788
+ rb_define_method(inline_fragment_class, "type_condition", inline_fragment_get_type_condition, 0);
789
+ rb_define_method(inline_fragment_class, "directives_size", inline_fragment_get_directives_size, 0);
790
+ rb_define_method(inline_fragment_class, "selection_set", inline_fragment_get_selection_set, 0);
791
+ rb_define_method(fragment_definition_class, "name", fragment_definition_get_name, 0);
792
+ rb_define_method(fragment_definition_class, "type_condition", fragment_definition_get_type_condition, 0);
793
+ rb_define_method(fragment_definition_class, "directives_size", fragment_definition_get_directives_size, 0);
794
+ rb_define_method(fragment_definition_class, "selection_set", fragment_definition_get_selection_set, 0);
795
+ rb_define_method(variable_class, "name", variable_get_name, 0);
796
+ rb_define_method(int_value_class, "value", int_value_get_value, 0);
797
+ rb_define_method(float_value_class, "value", float_value_get_value, 0);
798
+ rb_define_method(string_value_class, "value", string_value_get_value, 0);
799
+ rb_define_method(boolean_value_class, "value", boolean_value_get_value, 0);
800
+ rb_define_method(enum_value_class, "value", enum_value_get_value, 0);
801
+ rb_define_method(array_value_class, "values_size", array_value_get_values_size, 0);
802
+ rb_define_method(object_value_class, "fields_size", object_value_get_fields_size, 0);
803
+ rb_define_method(object_field_class, "name", object_field_get_name, 0);
804
+ rb_define_method(object_field_class, "value", object_field_get_value, 0);
805
+ rb_define_method(directive_class, "name", directive_get_name, 0);
806
+ rb_define_method(directive_class, "arguments_size", directive_get_arguments_size, 0);
807
+ rb_define_method(named_type_class, "name", named_type_get_name, 0);
808
+ rb_define_method(list_type_class, "type", list_type_get_type, 0);
809
+ rb_define_method(non_null_type_class, "type", non_null_type_get_type, 0);
810
+ rb_define_method(name_class, "value", name_get_value, 0);
811
+
812
+ visit_document_id = rb_intern("visit_document");
813
+ end_visit_document_id = rb_intern("end_visit_document");
814
+ visit_operation_definition_id = rb_intern("visit_operation_definition");
815
+ end_visit_operation_definition_id = rb_intern("end_visit_operation_definition");
816
+ visit_variable_definition_id = rb_intern("visit_variable_definition");
817
+ end_visit_variable_definition_id = rb_intern("end_visit_variable_definition");
818
+ visit_selection_set_id = rb_intern("visit_selection_set");
819
+ end_visit_selection_set_id = rb_intern("end_visit_selection_set");
820
+ visit_field_id = rb_intern("visit_field");
821
+ end_visit_field_id = rb_intern("end_visit_field");
822
+ visit_argument_id = rb_intern("visit_argument");
823
+ end_visit_argument_id = rb_intern("end_visit_argument");
824
+ visit_fragment_spread_id = rb_intern("visit_fragment_spread");
825
+ end_visit_fragment_spread_id = rb_intern("end_visit_fragment_spread");
826
+ visit_inline_fragment_id = rb_intern("visit_inline_fragment");
827
+ end_visit_inline_fragment_id = rb_intern("end_visit_inline_fragment");
828
+ visit_fragment_definition_id = rb_intern("visit_fragment_definition");
829
+ end_visit_fragment_definition_id = rb_intern("end_visit_fragment_definition");
830
+ visit_variable_id = rb_intern("visit_variable");
831
+ end_visit_variable_id = rb_intern("end_visit_variable");
832
+ visit_int_value_id = rb_intern("visit_int_value");
833
+ end_visit_int_value_id = rb_intern("end_visit_int_value");
834
+ visit_float_value_id = rb_intern("visit_float_value");
835
+ end_visit_float_value_id = rb_intern("end_visit_float_value");
836
+ visit_string_value_id = rb_intern("visit_string_value");
837
+ end_visit_string_value_id = rb_intern("end_visit_string_value");
838
+ visit_boolean_value_id = rb_intern("visit_boolean_value");
839
+ end_visit_boolean_value_id = rb_intern("end_visit_boolean_value");
840
+ visit_enum_value_id = rb_intern("visit_enum_value");
841
+ end_visit_enum_value_id = rb_intern("end_visit_enum_value");
842
+ visit_array_value_id = rb_intern("visit_array_value");
843
+ end_visit_array_value_id = rb_intern("end_visit_array_value");
844
+ visit_object_value_id = rb_intern("visit_object_value");
845
+ end_visit_object_value_id = rb_intern("end_visit_object_value");
846
+ visit_object_field_id = rb_intern("visit_object_field");
847
+ end_visit_object_field_id = rb_intern("end_visit_object_field");
848
+ visit_directive_id = rb_intern("visit_directive");
849
+ end_visit_directive_id = rb_intern("end_visit_directive");
850
+ visit_named_type_id = rb_intern("visit_named_type");
851
+ end_visit_named_type_id = rb_intern("end_visit_named_type");
852
+ visit_list_type_id = rb_intern("visit_list_type");
853
+ end_visit_list_type_id = rb_intern("end_visit_list_type");
854
+ visit_non_null_type_id = rb_intern("visit_non_null_type");
855
+ end_visit_non_null_type_id = rb_intern("end_visit_non_null_type");
856
+ visit_name_id = rb_intern("visit_name");
857
+ end_visit_name_id = rb_intern("end_visit_name");
858
+
859
+ cbs.visit_document = visit_document;
860
+ cbs.end_visit_document = end_visit_document;
861
+ cbs.visit_operation_definition = visit_operation_definition;
862
+ cbs.end_visit_operation_definition = end_visit_operation_definition;
863
+ cbs.visit_variable_definition = visit_variable_definition;
864
+ cbs.end_visit_variable_definition = end_visit_variable_definition;
865
+ cbs.visit_selection_set = visit_selection_set;
866
+ cbs.end_visit_selection_set = end_visit_selection_set;
867
+ cbs.visit_field = visit_field;
868
+ cbs.end_visit_field = end_visit_field;
869
+ cbs.visit_argument = visit_argument;
870
+ cbs.end_visit_argument = end_visit_argument;
871
+ cbs.visit_fragment_spread = visit_fragment_spread;
872
+ cbs.end_visit_fragment_spread = end_visit_fragment_spread;
873
+ cbs.visit_inline_fragment = visit_inline_fragment;
874
+ cbs.end_visit_inline_fragment = end_visit_inline_fragment;
875
+ cbs.visit_fragment_definition = visit_fragment_definition;
876
+ cbs.end_visit_fragment_definition = end_visit_fragment_definition;
877
+ cbs.visit_variable = visit_variable;
878
+ cbs.end_visit_variable = end_visit_variable;
879
+ cbs.visit_int_value = visit_int_value;
880
+ cbs.end_visit_int_value = end_visit_int_value;
881
+ cbs.visit_float_value = visit_float_value;
882
+ cbs.end_visit_float_value = end_visit_float_value;
883
+ cbs.visit_string_value = visit_string_value;
884
+ cbs.end_visit_string_value = end_visit_string_value;
885
+ cbs.visit_boolean_value = visit_boolean_value;
886
+ cbs.end_visit_boolean_value = end_visit_boolean_value;
887
+ cbs.visit_enum_value = visit_enum_value;
888
+ cbs.end_visit_enum_value = end_visit_enum_value;
889
+ cbs.visit_array_value = visit_array_value;
890
+ cbs.end_visit_array_value = end_visit_array_value;
891
+ cbs.visit_object_value = visit_object_value;
892
+ cbs.end_visit_object_value = end_visit_object_value;
893
+ cbs.visit_object_field = visit_object_field;
894
+ cbs.end_visit_object_field = end_visit_object_field;
895
+ cbs.visit_directive = visit_directive;
896
+ cbs.end_visit_directive = end_visit_directive;
897
+ cbs.visit_named_type = visit_named_type;
898
+ cbs.end_visit_named_type = end_visit_named_type;
899
+ cbs.visit_list_type = visit_list_type;
900
+ cbs.end_visit_list_type = end_visit_list_type;
901
+ cbs.visit_non_null_type = visit_non_null_type;
902
+ cbs.end_visit_non_null_type = end_visit_non_null_type;
903
+ cbs.visit_name = visit_name;
904
+ cbs.end_visit_name = end_visit_name;
905
+
906
+ }