gql 0.0.17 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gql/array.rb +11 -11
- data/lib/gql/boolean.rb +1 -1
- data/lib/gql/call.rb +1 -1
- data/lib/gql/config.rb +23 -23
- data/lib/gql/connection.rb +6 -6
- data/lib/gql/errors.rb +30 -30
- data/lib/gql/executor.rb +4 -4
- data/lib/gql/{node.rb → field.rb} +5 -5
- data/lib/gql/has_calls.rb +4 -4
- data/lib/gql/has_fields.rb +4 -4
- data/lib/gql/number.rb +1 -1
- data/lib/gql/object.rb +4 -4
- data/lib/gql/parser.rb +10 -10
- data/lib/gql/scalar.rb +7 -0
- data/lib/gql/schema/call.rb +4 -4
- data/lib/gql/schema/caller_class.rb +1 -1
- data/lib/gql/schema/field.rb +4 -4
- data/lib/gql/schema/list.rb +1 -1
- data/lib/gql/schema/parameter.rb +2 -2
- data/lib/gql/string.rb +1 -1
- data/lib/gql/tokenizer.rb +8 -5
- data/lib/gql/version.rb +1 -1
- data/lib/gql.rb +6 -6
- metadata +3 -3
- data/lib/gql/raw.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd01c67b3f0e68e96e94cccf2b52bdc7b0ef4683
|
4
|
+
data.tar.gz: e525e23f3345a58363e33af7c693cc5becc1570c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5141e572b5eab687f99263e6195a146e0aff74a4ce8361abb1ef7eccacfcb6f785de58c9a9c5c908bc978701368382cf325d92a4024c0be4acdf42e4eb8521be
|
7
|
+
data.tar.gz: 633ae172c44ba70a937e0ab61ffb8fbff011f2b1ed6d172bb0f7ded9054c31203c33bc29fdad41aa4c95fcdfb603fb5c35811620a97a08d1aafd5b00edf66af9
|
data/lib/gql/array.rb
CHANGED
@@ -1,34 +1,34 @@
|
|
1
1
|
require 'active_support/core_ext/class/attribute'
|
2
2
|
|
3
3
|
module GQL
|
4
|
-
class Array <
|
5
|
-
class_attribute :
|
4
|
+
class Array < Field
|
5
|
+
class_attribute :item_field_class, instance_accessor: false, instance_predicate: false
|
6
6
|
|
7
7
|
class << self
|
8
8
|
def build_class(id, proc, options = {})
|
9
|
-
|
9
|
+
item_field_class = options.delete(:item_field_class) || self.item_field_class
|
10
10
|
|
11
|
-
if
|
12
|
-
|
13
|
-
|
11
|
+
if item_field_class.is_a?(Hash)
|
12
|
+
item_field_class.values.each do |klass|
|
13
|
+
Field.validate_is_subclass! klass, 'item'
|
14
14
|
end
|
15
15
|
else
|
16
|
-
|
17
|
-
|
16
|
+
Field.validate_is_subclass! item_field_class, 'item'
|
17
|
+
item_field_class = Hash.new(item_field_class)
|
18
18
|
end
|
19
19
|
|
20
20
|
Class.new(self).tap do |field_class|
|
21
21
|
field_class.id = id.to_s
|
22
22
|
field_class.proc = proc
|
23
|
-
field_class.
|
23
|
+
field_class.item_field_class = item_field_class
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
def value
|
29
29
|
target.map do |item|
|
30
|
-
|
31
|
-
|
30
|
+
field = self.class.item_field_class[item.class].new(ast_node, item, variables, context)
|
31
|
+
field.value
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
data/lib/gql/boolean.rb
CHANGED
data/lib/gql/call.rb
CHANGED
data/lib/gql/config.rb
CHANGED
@@ -2,16 +2,16 @@ require 'active_support/core_ext/class/subclasses'
|
|
2
2
|
|
3
3
|
module GQL
|
4
4
|
class Config
|
5
|
-
def
|
6
|
-
@@
|
5
|
+
def root_field_class
|
6
|
+
@@root_field_class ||= nil
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
unless value.nil? || value <=
|
11
|
-
raise Errors::
|
9
|
+
def root_field_class=(value)
|
10
|
+
unless value.nil? || value <= Field
|
11
|
+
raise Errors::InvalidFieldClass.new(value, Field)
|
12
12
|
end
|
13
13
|
|
14
|
-
@@
|
14
|
+
@@root_field_class = value
|
15
15
|
end
|
16
16
|
|
17
17
|
def root_target_proc
|
@@ -37,16 +37,16 @@ module GQL
|
|
37
37
|
@@field_types = value
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
41
|
-
@@
|
40
|
+
def default_list_field_class
|
41
|
+
@@default_list_field_class ||= Field
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
45
|
-
unless value.nil? || value <=
|
46
|
-
raise Errors::
|
44
|
+
def default_list_field_class=(value)
|
45
|
+
unless value.nil? || value <= Field
|
46
|
+
raise Errors::InvalidFieldClass.new(value, Field)
|
47
47
|
end
|
48
48
|
|
49
|
-
@@
|
49
|
+
@@default_list_field_class = value
|
50
50
|
end
|
51
51
|
|
52
52
|
def default_field_proc
|
@@ -96,31 +96,31 @@ module GQL
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def switch_on_type_field
|
99
|
-
return if
|
99
|
+
return if Field.has_field? :__type__
|
100
100
|
|
101
|
-
type_field_class =
|
101
|
+
type_field_class = Field.object :__type__, -> { field_class }, field_class: Schema::Field
|
102
102
|
|
103
|
-
|
104
|
-
|
103
|
+
Field.descendants.each do |field_class|
|
104
|
+
field_class.fields[:__type__] = type_field_class
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
108
|
def switch_off_type_field
|
109
|
-
return unless
|
109
|
+
return unless Field.has_field? :__type__
|
110
110
|
|
111
|
-
[
|
112
|
-
|
111
|
+
[Field, *Field.descendants].each do |field_class|
|
112
|
+
field_class.remove_field :__type__
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
116
116
|
def switch_on_execution_context
|
117
|
-
|
118
|
-
|
117
|
+
Field.send :remove_const, :ExecutionContext if Field.const_defined?(:ExecutionContext)
|
118
|
+
Field.const_set :ExecutionContext, Field::ExecutionContextDebug
|
119
119
|
end
|
120
120
|
|
121
121
|
def switch_off_execution_context
|
122
|
-
|
123
|
-
|
122
|
+
Field.send :remove_const, :ExecutionContext if Field.const_defined?(:ExecutionContext)
|
123
|
+
Field.const_set :ExecutionContext, Field::ExecutionContextNoDebug
|
124
124
|
end
|
125
125
|
|
126
126
|
end
|
data/lib/gql/connection.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
require 'active_support/core_ext/class/attribute'
|
2
2
|
|
3
3
|
module GQL
|
4
|
-
class Connection <
|
4
|
+
class Connection < Field
|
5
5
|
class << self
|
6
6
|
def build_class(id, proc, options = {})
|
7
|
-
|
8
|
-
|
7
|
+
list_field_class = options.delete(:list_field_class) || GQL.default_list_field_class
|
8
|
+
item_field_class = options.delete(:item_field_class)
|
9
9
|
|
10
|
-
|
10
|
+
Field.validate_is_subclass! list_field_class, 'list'
|
11
11
|
|
12
|
-
|
13
|
-
field_class.array :edges, -> { target },
|
12
|
+
list_field_class.build_class(id, proc, options).tap do |field_class|
|
13
|
+
field_class.array :edges, -> { target }, item_field_class: item_field_class
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
data/lib/gql/errors.rb
CHANGED
@@ -28,26 +28,26 @@ module GQL
|
|
28
28
|
module Errors
|
29
29
|
class NotFoundError < Error
|
30
30
|
private
|
31
|
-
def construct_message(
|
32
|
-
items =
|
31
|
+
def construct_message(field_class, id, name, method)
|
32
|
+
items = field_class.send(method).keys.sort.map { |key| "`#{key}'" }
|
33
33
|
|
34
|
-
msg = "#{
|
34
|
+
msg = "#{field_class} has no #{name} named `#{id}'."
|
35
35
|
msg << " Available #{name.pluralize}: #{items.to_sentence}." if items.any?
|
36
36
|
msg
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
class CallNotFound < NotFoundError
|
41
|
-
def initialize(id,
|
42
|
-
msg = construct_message(
|
41
|
+
def initialize(id, field_class)
|
42
|
+
msg = construct_message(field_class, id, 'call', :calls)
|
43
43
|
|
44
44
|
super(msg, 111, id)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
class FieldNotFound < NotFoundError
|
49
|
-
def initialize(id,
|
50
|
-
msg = construct_message(
|
49
|
+
def initialize(id, field_class)
|
50
|
+
msg = construct_message(field_class, id, 'field', :fields)
|
51
51
|
|
52
52
|
super(msg, 112, id)
|
53
53
|
end
|
@@ -61,37 +61,46 @@ module GQL
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
class
|
64
|
+
class RootClassNotSet < Error
|
65
|
+
def initialize
|
66
|
+
msg = "GQL root field class is not set. "
|
67
|
+
msg << "Set it with `GQL.root_field_class = MyRootField'."
|
68
|
+
|
69
|
+
super(msg, 121)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
class FieldClassNotSet < Error
|
74
|
+
def initialize(node_class, name)
|
75
|
+
msg = "#{node_class} must have a #{name} class set. "
|
76
|
+
msg << "Set it with `self.#{name}_class = My#{name.camelize}Class'."
|
77
|
+
|
78
|
+
super(msg, 122)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
class InvalidFieldClass < Error
|
65
83
|
def initialize(node_class, super_class)
|
66
84
|
msg = "#{node_class} must be a (subclass of) #{super_class}."
|
67
85
|
|
68
|
-
super(msg,
|
86
|
+
super(msg, 123)
|
69
87
|
end
|
70
88
|
end
|
71
89
|
|
72
90
|
class NoMethodError < Error
|
73
91
|
attr_reader :cause
|
74
92
|
|
75
|
-
def initialize(
|
93
|
+
def initialize(field_class, id, cause)
|
76
94
|
@cause = cause
|
77
95
|
|
78
|
-
msg = "Undefined method `#{id}' for #{
|
96
|
+
msg = "Undefined method `#{id}' for #{field_class}. "
|
79
97
|
msg << "Did you try to add a field of type `#{id}'? "
|
80
98
|
msg << "If so, you have to register your field type first "
|
81
99
|
msg << "like this: `GQL.field_types[:#{id}] = My#{id.to_s.camelize}'. "
|
82
100
|
msg << "The following field types are currently registered: "
|
83
101
|
msg << GQL.field_types.keys.sort.map { |key| "`#{key}'" }.to_sentence
|
84
102
|
|
85
|
-
super(msg,
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
class RootClassNotSet < Error
|
90
|
-
def initialize
|
91
|
-
msg = "GQL root node class is not set. "
|
92
|
-
msg << "Set it with `GQL.root_node_class = MyRootNode'."
|
93
|
-
|
94
|
-
super(msg, 123)
|
103
|
+
super(msg, 124)
|
95
104
|
end
|
96
105
|
end
|
97
106
|
|
@@ -109,14 +118,5 @@ module GQL
|
|
109
118
|
super(msg, 132, value)
|
110
119
|
end
|
111
120
|
end
|
112
|
-
|
113
|
-
class UndefinedNodeClass < Error
|
114
|
-
def initialize(node_class, name)
|
115
|
-
msg = "#{node_class} must have a #{name} class set. "
|
116
|
-
msg << "Set it with `self.#{name}_class = My#{name.camelize}Class'."
|
117
|
-
|
118
|
-
super(msg, 124)
|
119
|
-
end
|
120
|
-
end
|
121
121
|
end
|
122
122
|
end
|
data/lib/gql/executor.rb
CHANGED
@@ -8,16 +8,16 @@ module GQL
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def execute(context = {}, vars = {})
|
11
|
-
|
11
|
+
field_class = GQL.root_field_class
|
12
12
|
|
13
|
-
raise Errors::RootClassNotSet if
|
13
|
+
raise Errors::RootClassNotSet if field_class.nil?
|
14
14
|
|
15
15
|
variables.update vars
|
16
16
|
|
17
17
|
target = GQL.root_target_proc.call(context)
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
field = field_class.new(ast_root, target, variables, context)
|
20
|
+
field.value
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -4,7 +4,7 @@ require 'gql/has_calls'
|
|
4
4
|
require 'gql/has_fields'
|
5
5
|
|
6
6
|
module GQL
|
7
|
-
class
|
7
|
+
class Field
|
8
8
|
class_attribute :id, :proc, instance_accessor: false, instance_predicate: false
|
9
9
|
|
10
10
|
class << self
|
@@ -17,11 +17,11 @@ module GQL
|
|
17
17
|
|
18
18
|
def validate_is_subclass!(subclass, name)
|
19
19
|
if subclass.nil?
|
20
|
-
raise Errors::
|
20
|
+
raise Errors::FieldClassNotSet.new(self, name)
|
21
21
|
end
|
22
22
|
|
23
23
|
unless subclass <= self
|
24
|
-
raise Errors::
|
24
|
+
raise Errors::InvalidFieldClass.new(subclass, self)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -42,11 +42,11 @@ module GQL
|
|
42
42
|
elsif ast_fields = ast_node.fields
|
43
43
|
value_of_fields ast_fields
|
44
44
|
else
|
45
|
-
|
45
|
+
scalar_value
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
def
|
49
|
+
def scalar_value
|
50
50
|
nil
|
51
51
|
end
|
52
52
|
end
|
data/lib/gql/has_calls.rb
CHANGED
@@ -21,7 +21,7 @@ module GQL
|
|
21
21
|
result_spec = options[:returns] || call_spec.try(:result_class)
|
22
22
|
result_class = result_class_from_spec(result_spec)
|
23
23
|
|
24
|
-
|
24
|
+
Field.validate_is_subclass! result_class, 'result' if result_class
|
25
25
|
|
26
26
|
call_class = call_class_from_spec(call_spec)
|
27
27
|
call_class.id = id.to_s
|
@@ -65,12 +65,12 @@ module GQL
|
|
65
65
|
|
66
66
|
def result_class_from_connection_spec(spec)
|
67
67
|
if spec.size == 1
|
68
|
-
spec.unshift GQL.
|
68
|
+
spec.unshift GQL.default_list_field_class
|
69
69
|
end
|
70
70
|
|
71
71
|
options = {
|
72
|
-
|
73
|
-
|
72
|
+
list_field_class: spec.first,
|
73
|
+
item_field_class: spec.last
|
74
74
|
}
|
75
75
|
|
76
76
|
Connection.build_class :result, nil, options
|
data/lib/gql/has_fields.rb
CHANGED
@@ -15,10 +15,10 @@ module GQL
|
|
15
15
|
module ClassMethods
|
16
16
|
def add_field(id, *args, &block)
|
17
17
|
options = args.extract_options!
|
18
|
-
type = options.delete(:type) ||
|
18
|
+
type = options.delete(:type) || Field
|
19
19
|
proc = args.shift || block || proc_for_field(id)
|
20
20
|
|
21
|
-
|
21
|
+
Field.validate_is_subclass! type, 'type'
|
22
22
|
|
23
23
|
type.build_class(id, proc, options).tap do |field_class|
|
24
24
|
const_name = const_name_for_field(id)
|
@@ -45,7 +45,7 @@ module GQL
|
|
45
45
|
id = id_or_proc.is_a?(Proc) ? nil : id_or_proc
|
46
46
|
proc = id ? -> { target.public_send(id) } : id_or_proc
|
47
47
|
|
48
|
-
add_field :cursor, proc, type:
|
48
|
+
add_field :cursor, proc, type: Scalar
|
49
49
|
end
|
50
50
|
|
51
51
|
def respond_to?(method, *args)
|
@@ -74,7 +74,7 @@ module GQL
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def define_field_method(name, type)
|
77
|
-
|
77
|
+
Field.define_singleton_method name do |*args, &block|
|
78
78
|
options = args.extract_options!.merge(type: type)
|
79
79
|
args = args.push(options)
|
80
80
|
|
data/lib/gql/number.rb
CHANGED
data/lib/gql/object.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'active_support/core_ext/class/attribute'
|
2
2
|
|
3
3
|
module GQL
|
4
|
-
class Object <
|
4
|
+
class Object < Field
|
5
5
|
class << self
|
6
6
|
def build_class(id, proc, options = {})
|
7
|
-
|
7
|
+
field_class = options.delete(:field_class)
|
8
8
|
|
9
|
-
|
9
|
+
Field.validate_is_subclass! field_class, 'field'
|
10
10
|
|
11
|
-
|
11
|
+
field_class.build_class id, proc, options
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
data/lib/gql/parser.rb
CHANGED
@@ -27,7 +27,7 @@ module_eval(<<'...end parser.racc/module_eval...', 'parser.racc', 136)
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
class
|
30
|
+
class Field < Struct.new(:id, :alias_id, :call, :fields)
|
31
31
|
def as_json(*)
|
32
32
|
{
|
33
33
|
id: id,
|
@@ -301,14 +301,14 @@ module_eval(<<'.,.,', 'parser.racc', 4)
|
|
301
301
|
|
302
302
|
module_eval(<<'.,.,', 'parser.racc', 8)
|
303
303
|
def _reduce_2(val, _values, result)
|
304
|
-
result =
|
304
|
+
result = Field.new('[root]', nil, val[0], nil )
|
305
305
|
result
|
306
306
|
end
|
307
307
|
.,.,
|
308
308
|
|
309
309
|
module_eval(<<'.,.,', 'parser.racc', 9)
|
310
310
|
def _reduce_3(val, _values, result)
|
311
|
-
result =
|
311
|
+
result = Field.new('[root]', nil, nil, val[1])
|
312
312
|
result
|
313
313
|
end
|
314
314
|
.,.,
|
@@ -403,49 +403,49 @@ module_eval(<<'.,.,', 'parser.racc', 41)
|
|
403
403
|
|
404
404
|
module_eval(<<'.,.,', 'parser.racc', 45)
|
405
405
|
def _reduce_18(val, _values, result)
|
406
|
-
result =
|
406
|
+
result = Field.new(val[0], val[2], nil, val[1].presence)
|
407
407
|
result
|
408
408
|
end
|
409
409
|
.,.,
|
410
410
|
|
411
411
|
module_eval(<<'.,.,', 'parser.racc', 46)
|
412
412
|
def _reduce_19(val, _values, result)
|
413
|
-
result =
|
413
|
+
result = Field.new(val[0], val[1], nil, val[2].presence)
|
414
414
|
result
|
415
415
|
end
|
416
416
|
.,.,
|
417
417
|
|
418
418
|
module_eval(<<'.,.,', 'parser.racc', 47)
|
419
419
|
def _reduce_20(val, _values, result)
|
420
|
-
result =
|
420
|
+
result = Field.new(val[0], val[3], val[2], nil )
|
421
421
|
result
|
422
422
|
end
|
423
423
|
.,.,
|
424
424
|
|
425
425
|
module_eval(<<'.,.,', 'parser.racc', 48)
|
426
426
|
def _reduce_21(val, _values, result)
|
427
|
-
result =
|
427
|
+
result = Field.new(val[0], val[1], nil, nil )
|
428
428
|
result
|
429
429
|
end
|
430
430
|
.,.,
|
431
431
|
|
432
432
|
module_eval(<<'.,.,', 'parser.racc', 49)
|
433
433
|
def _reduce_22(val, _values, result)
|
434
|
-
result =
|
434
|
+
result = Field.new(val[0], nil, nil, val[1].presence)
|
435
435
|
result
|
436
436
|
end
|
437
437
|
.,.,
|
438
438
|
|
439
439
|
module_eval(<<'.,.,', 'parser.racc', 50)
|
440
440
|
def _reduce_23(val, _values, result)
|
441
|
-
result =
|
441
|
+
result = Field.new(val[0], nil, val[2], nil )
|
442
442
|
result
|
443
443
|
end
|
444
444
|
.,.,
|
445
445
|
|
446
446
|
module_eval(<<'.,.,', 'parser.racc', 51)
|
447
447
|
def _reduce_24(val, _values, result)
|
448
|
-
result =
|
448
|
+
result = Field.new(val[0], nil, nil, nil )
|
449
449
|
result
|
450
450
|
end
|
451
451
|
.,.,
|
data/lib/gql/scalar.rb
ADDED
data/lib/gql/schema/call.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module GQL
|
2
2
|
module Schema
|
3
|
-
class Call < GQL::
|
3
|
+
class Call < GQL::Field
|
4
4
|
cursor :id
|
5
5
|
|
6
6
|
string :id
|
7
7
|
string :name
|
8
|
-
object :result_class, -> { target.result_class || CallerClass },
|
9
|
-
array :parameters, -> { (target.proc || target.instance_method(:execute)).parameters },
|
8
|
+
object :result_class, -> { target.result_class || CallerClass }, field_class: Field
|
9
|
+
array :parameters, -> { (target.proc || target.instance_method(:execute)).parameters }, item_field_class: Parameter
|
10
10
|
|
11
|
-
def
|
11
|
+
def scalar_value
|
12
12
|
target.name
|
13
13
|
end
|
14
14
|
end
|
data/lib/gql/schema/field.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module GQL
|
2
2
|
module Schema
|
3
|
-
class Field < GQL::
|
3
|
+
class Field < GQL::Field
|
4
4
|
cursor :id
|
5
5
|
|
6
6
|
string :id
|
7
7
|
string :name
|
8
|
-
connection :calls, -> { target.calls.values },
|
9
|
-
connection :fields, -> { target.fields.values },
|
8
|
+
connection :calls, -> { target.calls.values }, list_field_class: List, item_field_class: Call
|
9
|
+
connection :fields, -> { target.fields.values }, list_field_class: List, item_field_class: Field
|
10
10
|
|
11
|
-
def
|
11
|
+
def scalar_value
|
12
12
|
target.name
|
13
13
|
end
|
14
14
|
end
|
data/lib/gql/schema/list.rb
CHANGED
data/lib/gql/schema/parameter.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module GQL
|
2
2
|
module Schema
|
3
|
-
class Parameter < GQL::
|
3
|
+
class Parameter < GQL::Field
|
4
4
|
TYPES = {
|
5
5
|
req: 'required',
|
6
6
|
opt: 'optional',
|
@@ -16,7 +16,7 @@ module GQL
|
|
16
16
|
string :id, -> { target[1].to_s }
|
17
17
|
string :type, -> { TYPES[target[0]] || target[0].to_s }
|
18
18
|
|
19
|
-
def
|
19
|
+
def scalar_value
|
20
20
|
"#{target[1]} (#{TYPES[target[0]] || target[0]})"
|
21
21
|
end
|
22
22
|
end
|
data/lib/gql/string.rb
CHANGED
data/lib/gql/tokenizer.rb
CHANGED
@@ -69,22 +69,25 @@ class GQL::Tokenizer < Racc::Parser
|
|
69
69
|
when (text = @ss.scan(/-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/))
|
70
70
|
action { [:NUMBER, text] }
|
71
71
|
|
72
|
-
when (text = @ss.scan(/true/))
|
72
|
+
when (text = @ss.scan(/true\b/))
|
73
73
|
action { [:TRUE, text] }
|
74
74
|
|
75
|
-
when (text = @ss.scan(/false/))
|
75
|
+
when (text = @ss.scan(/false\b/))
|
76
76
|
action { [:FALSE, text] }
|
77
77
|
|
78
|
-
when (text = @ss.scan(/null/))
|
78
|
+
when (text = @ss.scan(/null\b/))
|
79
79
|
action { [:NULL, text] }
|
80
80
|
|
81
|
-
when (text = @ss.scan(/[aA][sS]/))
|
81
|
+
when (text = @ss.scan(/[aA][sS]\b/))
|
82
82
|
action { [:AS, text] }
|
83
83
|
|
84
84
|
when (text = @ss.scan(/[a-zA-Z_][a-zA-Z0-9_]*/))
|
85
85
|
action { [:IDENT, text] }
|
86
86
|
|
87
|
-
when (text = @ss.scan(
|
87
|
+
when (text = @ss.scan(/(?:[[:blank:]]|\f)+/))
|
88
|
+
;
|
89
|
+
|
90
|
+
when (text = @ss.scan(/\r?\n/))
|
88
91
|
;
|
89
92
|
|
90
93
|
when (text = @ss.scan(/./))
|
data/lib/gql/version.rb
CHANGED
data/lib/gql.rb
CHANGED
@@ -11,11 +11,11 @@ module GQL
|
|
11
11
|
autoload :Connection
|
12
12
|
autoload :Error, 'gql/errors'
|
13
13
|
autoload :Executor
|
14
|
-
autoload :
|
14
|
+
autoload :Field
|
15
15
|
autoload :Number
|
16
16
|
autoload :Object
|
17
17
|
autoload :Parser
|
18
|
-
autoload :
|
18
|
+
autoload :Scalar
|
19
19
|
autoload :String
|
20
20
|
autoload :TestCase
|
21
21
|
autoload :Tokenizer
|
@@ -25,13 +25,13 @@ module GQL
|
|
25
25
|
|
26
26
|
autoload_at 'gql/errors' do
|
27
27
|
autoload :CallNotFound
|
28
|
+
autoload :FieldClassNotSet
|
28
29
|
autoload :FieldNotFound
|
29
|
-
autoload :
|
30
|
+
autoload :InvalidFieldClass
|
30
31
|
autoload :NoMethodError
|
31
32
|
autoload :RootClassNotSet
|
32
33
|
autoload :ScanError
|
33
34
|
autoload :SyntaxError
|
34
|
-
autoload :UndefinedNodeClass
|
35
35
|
autoload :VariableNotFound
|
36
36
|
end
|
37
37
|
end
|
@@ -55,8 +55,8 @@ module GQL
|
|
55
55
|
Thread.current[:gql_config] = value
|
56
56
|
end
|
57
57
|
|
58
|
-
%w(
|
59
|
-
|
58
|
+
%w(root_field_class root_target_proc field_types
|
59
|
+
default_list_field_class default_field_proc
|
60
60
|
default_call_proc debug).each do |method|
|
61
61
|
module_eval <<-DELEGATORS, __FILE__, __LINE__ + 1
|
62
62
|
def #{method}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Andert
|
@@ -111,13 +111,13 @@ files:
|
|
111
111
|
- lib/gql/connection.rb
|
112
112
|
- lib/gql/errors.rb
|
113
113
|
- lib/gql/executor.rb
|
114
|
+
- lib/gql/field.rb
|
114
115
|
- lib/gql/has_calls.rb
|
115
116
|
- lib/gql/has_fields.rb
|
116
|
-
- lib/gql/node.rb
|
117
117
|
- lib/gql/number.rb
|
118
118
|
- lib/gql/object.rb
|
119
119
|
- lib/gql/parser.rb
|
120
|
-
- lib/gql/
|
120
|
+
- lib/gql/scalar.rb
|
121
121
|
- lib/gql/schema/call.rb
|
122
122
|
- lib/gql/schema/caller_class.rb
|
123
123
|
- lib/gql/schema/field.rb
|