tinygql 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 445c7c3eccff7132942d89394f68b4d1f9b431b31ce8c69ed5411e07d9c35ee4
4
- data.tar.gz: 26a1faa1b1a29a76ce1c3fdaabecd413816fd96eeffc2663f0b6d99dd27beeb2
3
+ metadata.gz: ef7a07443c070f78f1ad6324890611e1ea70298c7d67eac591911c208b42aa0f
4
+ data.tar.gz: 3311b13953c075059a737b46f82f50aa3fd2428d844499c64354a285aa2774cd
5
5
  SHA512:
6
- metadata.gz: 9825170ead631c309d1fae5e918c232102ff9673b686365b37cf60d8bd0f07a5888d42848d1f0a9eb529a3c5fe58fc47b066741c29de7bd236be10d3b7587fb6
7
- data.tar.gz: c8a569419d177b5c06ee73cbf69b38290cefe40b3c781e6c730ca95ce8b2e978254b9465a0ea37d9c29c29388d2c7ffab2fd247ab193322bd9797cc35920c27f
6
+ metadata.gz: 814659e285e05236a4861931cf548eabab4abeaccdbc5b959adc12e3a3e6f6b9a67ea5626117ae44f46a9316c8d3210adafbf269730aec23b8c9d5ac0a538832
7
+ data.tar.gz: 3603440c4c6aa2aed7c361439299b8218b2f01a2c5ea96ed100da5028ac6fe391d62322a4431124861db7de50c60c69fd50d3da92178c12ef04dd58fbe63e2d3
data/lib/tinygql/nodes.rb CHANGED
@@ -42,6 +42,11 @@ module TinyGQL
42
42
  def executable_directive_location?; false; end
43
43
  def type_system_directive_location?; false; end
44
44
  def directive_definition?; false; end
45
+ def scalar_type_extension?; false; end
46
+ def interface_type_extension?; false; end
47
+ def union_type_extension?; false; end
48
+ def enum_type_extension?; false; end
49
+ def input_object_type_extension?; false; end
45
50
  def each(&blk)
46
51
  yield self
47
52
  children.each { |v| v.each(&blk) }
@@ -422,7 +427,7 @@ module TinyGQL
422
427
  def directive?; true; end
423
428
 
424
429
  def children
425
- ary = []; ary.concat(arguments); ary
430
+ ary = []; ary.concat(arguments) if arguments; ary
426
431
  end
427
432
  end
428
433
  class TypeCondition < Node
@@ -488,7 +493,7 @@ module TinyGQL
488
493
  def fragment_spread?; true; end
489
494
 
490
495
  def children
491
- ary = []; ary << fragment_name; ary.concat(directives) if directives; ary
496
+ ary = []; ary.concat(directives) if directives; ary
492
497
  end
493
498
  end
494
499
  class FragmentDefinition < Node
@@ -512,7 +517,7 @@ module TinyGQL
512
517
  def fragment_definition?; true; end
513
518
 
514
519
  def children
515
- ary = []; ary << fragment_name; ary << type_condition; ary.concat(directives) if directives; ary.concat(selection_set); ary
520
+ ary = []; ary << type_condition; ary.concat(directives) if directives; ary.concat(selection_set); ary
516
521
  end
517
522
  end
518
523
  class RootOperationTypeDefinition < Node
@@ -534,7 +539,7 @@ module TinyGQL
534
539
  def root_operation_type_definition?; true; end
535
540
 
536
541
  def children
537
- ary = []; ary << operation_type; ary << named_type; ary
542
+ ary = []; ary << named_type; ary
538
543
  end
539
544
  end
540
545
  class SchemaDefinition < Node
@@ -557,7 +562,7 @@ module TinyGQL
557
562
  def schema_definition?; true; end
558
563
 
559
564
  def children
560
- ary = []; ary.concat(directives) if directives; ary.concat(root_operation_definitions); ary
565
+ ary = []; ary << description if description; ary.concat(directives) if directives; ary.concat(root_operation_definitions); ary
561
566
  end
562
567
  end
563
568
  class FieldDefinition < Node
@@ -582,7 +587,7 @@ module TinyGQL
582
587
  def field_definition?; true; end
583
588
 
584
589
  def children
585
- ary = []; ary.concat(arguments_definition) if arguments_definition; ary << type; ary.concat(directives) if directives; ary
590
+ ary = []; ary << description if description; ary.concat(arguments_definition) if arguments_definition; ary << type; ary.concat(directives) if directives; ary
586
591
  end
587
592
  end
588
593
  class InputValueDefinition < Node
@@ -607,7 +612,7 @@ module TinyGQL
607
612
  def input_value_definition?; true; end
608
613
 
609
614
  def children
610
- ary = []; ary << type; ary << default_value if default_value; ary.concat(directives) if directives; ary
615
+ ary = []; ary << description if description; ary << type; ary << default_value if default_value; ary.concat(directives) if directives; ary
611
616
  end
612
617
  end
613
618
  class ObjectTypeDefinition < Node
@@ -632,7 +637,7 @@ module TinyGQL
632
637
  def object_type_definition?; true; end
633
638
 
634
639
  def children
635
- ary = []; ary.concat(implements_interfaces) if implements_interfaces; ary.concat(directives) if directives; ary.concat(fields_definition) if fields_definition; ary
640
+ ary = []; ary << description if description; ary.concat(implements_interfaces) if implements_interfaces; ary.concat(directives) if directives; ary.concat(fields_definition) if fields_definition; ary
636
641
  end
637
642
  end
638
643
  class InterfaceTypeDefinition < Node
@@ -656,7 +661,7 @@ module TinyGQL
656
661
  def interface_type_definition?; true; end
657
662
 
658
663
  def children
659
- ary = []; ary.concat(directives) if directives; ary.concat(fields_definition) if fields_definition; ary
664
+ ary = []; ary << description if description; ary.concat(directives) if directives; ary.concat(fields_definition) if fields_definition; ary
660
665
  end
661
666
  end
662
667
  class UnionTypeDefinition < Node
@@ -680,7 +685,7 @@ module TinyGQL
680
685
  def union_type_definition?; true; end
681
686
 
682
687
  def children
683
- ary = []; ary.concat(directives) if directives; ary.concat(union_member_types) if union_member_types; ary
688
+ ary = []; ary << description if description; ary.concat(directives) if directives; ary.concat(union_member_types) if union_member_types; ary
684
689
  end
685
690
  end
686
691
  class ScalarTypeDefinition < Node
@@ -703,7 +708,7 @@ module TinyGQL
703
708
  def scalar_type_definition?; true; end
704
709
 
705
710
  def children
706
- ary = []; ary.concat(directives) if directives; ary
711
+ ary = []; ary << description if description; ary.concat(directives) if directives; ary
707
712
  end
708
713
  end
709
714
  class EnumValueDefinition < Node
@@ -726,7 +731,7 @@ module TinyGQL
726
731
  def enum_value_definition?; true; end
727
732
 
728
733
  def children
729
- ary = []; ary << enum_value; ary.concat(directives) if directives; ary
734
+ ary = []; ary << description if description; ary << enum_value; ary.concat(directives) if directives; ary
730
735
  end
731
736
  end
732
737
  class EnumTypeDefinition < Node
@@ -750,7 +755,7 @@ module TinyGQL
750
755
  def enum_type_definition?; true; end
751
756
 
752
757
  def children
753
- ary = []; ary.concat(directives) if directives; ary.concat(enum_value_definition) if enum_value_definition; ary
758
+ ary = []; ary << description if description; ary.concat(directives) if directives; ary.concat(enum_value_definition) if enum_value_definition; ary
754
759
  end
755
760
  end
756
761
  class InputObjectTypeDefinition < Node
@@ -774,7 +779,7 @@ module TinyGQL
774
779
  def input_object_type_definition?; true; end
775
780
 
776
781
  def children
777
- ary = []; ary.concat(directives) if directives; ary.concat(input_fields_definition) if input_fields_definition; ary
782
+ ary = []; ary << description if description; ary.concat(directives) if directives; ary.concat(input_fields_definition) if input_fields_definition; ary
778
783
  end
779
784
  end
780
785
  class ObjectTypeExtension < Node
@@ -864,7 +869,122 @@ module TinyGQL
864
869
  def directive_definition?; true; end
865
870
 
866
871
  def children
867
- ary = []; ary.concat(arguments_definition) if arguments_definition; ary.concat(directive_locations); ary
872
+ ary = []; ary << description if description; ary.concat(arguments_definition) if arguments_definition; ary.concat(directive_locations); ary
873
+ end
874
+ end
875
+ class ScalarTypeExtension < Node
876
+ attr_reader :name, :directives
877
+
878
+ def initialize name, directives
879
+ @name = name
880
+ @directives = directives
881
+ end
882
+
883
+ def accept viz
884
+ viz.handle_scalar_type_extension self
885
+ end
886
+
887
+ def fold viz, seed
888
+ viz.handle_scalar_type_extension self, seed
889
+ end
890
+
891
+ def scalar_type_extension?; true; end
892
+
893
+ def children
894
+ ary = []; ary.concat(directives) if directives; ary
895
+ end
896
+ end
897
+ class InterfaceTypeExtension < Node
898
+ attr_reader :name, :implements_interfaces, :directives, :fields_definition
899
+
900
+ def initialize name, implements_interfaces, directives, fields_definition
901
+ @name = name
902
+ @implements_interfaces = implements_interfaces
903
+ @directives = directives
904
+ @fields_definition = fields_definition
905
+ end
906
+
907
+ def accept viz
908
+ viz.handle_interface_type_extension self
909
+ end
910
+
911
+ def fold viz, seed
912
+ viz.handle_interface_type_extension self, seed
913
+ end
914
+
915
+ def interface_type_extension?; true; end
916
+
917
+ def children
918
+ ary = []; ary.concat(implements_interfaces) if implements_interfaces; ary.concat(directives) if directives; ary.concat(fields_definition) if fields_definition; ary
919
+ end
920
+ end
921
+ class UnionTypeExtension < Node
922
+ attr_reader :name, :directives, :union_member_types
923
+
924
+ def initialize name, directives, union_member_types
925
+ @name = name
926
+ @directives = directives
927
+ @union_member_types = union_member_types
928
+ end
929
+
930
+ def accept viz
931
+ viz.handle_union_type_extension self
932
+ end
933
+
934
+ def fold viz, seed
935
+ viz.handle_union_type_extension self, seed
936
+ end
937
+
938
+ def union_type_extension?; true; end
939
+
940
+ def children
941
+ ary = []; ary.concat(directives) if directives; ary.concat(union_member_types) if union_member_types; ary
942
+ end
943
+ end
944
+ class EnumTypeExtension < Node
945
+ attr_reader :name, :directives, :enum_value_definition
946
+
947
+ def initialize name, directives, enum_value_definition
948
+ @name = name
949
+ @directives = directives
950
+ @enum_value_definition = enum_value_definition
951
+ end
952
+
953
+ def accept viz
954
+ viz.handle_enum_type_extension self
955
+ end
956
+
957
+ def fold viz, seed
958
+ viz.handle_enum_type_extension self, seed
959
+ end
960
+
961
+ def enum_type_extension?; true; end
962
+
963
+ def children
964
+ ary = []; ary.concat(directives) if directives; ary.concat(enum_value_definition) if enum_value_definition; ary
965
+ end
966
+ end
967
+ class InputObjectTypeExtension < Node
968
+ attr_reader :name, :directives, :input_fields_definition
969
+
970
+ def initialize name, directives, input_fields_definition
971
+ @name = name
972
+ @directives = directives
973
+ @input_fields_definition = input_fields_definition
974
+ end
975
+
976
+ def accept viz
977
+ viz.handle_input_object_type_extension self
978
+ end
979
+
980
+ def fold viz, seed
981
+ viz.handle_input_object_type_extension self, seed
982
+ end
983
+
984
+ def input_object_type_extension?; true; end
985
+
986
+ def children
987
+ ary = []; ary.concat(directives) if directives; ary.concat(input_fields_definition) if input_fields_definition; ary
868
988
  end
869
989
  end
870
990
  end
@@ -84,7 +84,7 @@ nodes:
84
84
  - name: Directive
85
85
  fields:
86
86
  - name: literal
87
- - arguments: list
87
+ - arguments?: list
88
88
 
89
89
  - name: TypeCondition
90
90
  fields:
@@ -98,19 +98,19 @@ nodes:
98
98
 
99
99
  - name: FragmentSpread
100
100
  fields:
101
- - fragment_name
101
+ - fragment_name: literal
102
102
  - directives?: list
103
103
 
104
104
  - name: FragmentDefinition
105
105
  fields:
106
- - fragment_name
106
+ - fragment_name: literal
107
107
  - type_condition
108
108
  - directives?: list
109
109
  - selection_set: list
110
110
 
111
111
  - name: RootOperationTypeDefinition
112
112
  fields:
113
- - operation_type
113
+ - operation_type: literal
114
114
  - named_type
115
115
 
116
116
  - name: SchemaDefinition
@@ -204,3 +204,33 @@ nodes:
204
204
  - name: literal
205
205
  - arguments_definition?: list
206
206
  - directive_locations: list
207
+
208
+ - name: ScalarTypeExtension
209
+ fields:
210
+ - name: literal
211
+ - directives?: list
212
+
213
+ - name: InterfaceTypeExtension
214
+ fields:
215
+ - name: literal
216
+ - implements_interfaces?: list
217
+ - directives?: list
218
+ - fields_definition?: list
219
+
220
+ - name: UnionTypeExtension
221
+ fields:
222
+ - name: literal
223
+ - directives?: list
224
+ - union_member_types?: list
225
+
226
+ - name: EnumTypeExtension
227
+ fields:
228
+ - name: literal
229
+ - directives?: list
230
+ - enum_value_definition?: list
231
+
232
+ - name: InputObjectTypeExtension
233
+ fields:
234
+ - name: literal
235
+ - directives?: list
236
+ - input_fields_definition?: list
@@ -53,12 +53,57 @@ module TinyGQL
53
53
  def type_system_extension
54
54
  expect_token :EXTEND
55
55
  case token_name
56
+ when :SCALAR then scalar_type_extension
56
57
  when :TYPE then object_type_extension
58
+ when :INTERFACE then interface_type_extension
59
+ when :UNION then union_type_extension
60
+ when :ENUM then enum_type_extension
61
+ when :INPUT then input_object_type_extension
57
62
  else
58
- expect_token :FAIL
63
+ expect_token :SCALAR
59
64
  end
60
65
  end
61
66
 
67
+ def input_object_type_extension
68
+ expect_token :INPUT
69
+ name = self.name
70
+ directives = if at?(:DIR_SIGN); self.directives; end
71
+ input_fields_definition = if at?(:LCURLY); self.input_fields_definition; end
72
+ Nodes::InputObjectTypeExtension.new(name, directives, input_fields_definition)
73
+ end
74
+
75
+ def enum_type_extension
76
+ expect_token :ENUM
77
+ name = self.name
78
+ directives = if at?(:DIR_SIGN); self.directives; end
79
+ enum_values_definition = if at?(:LCURLY); self.enum_values_definition; end
80
+ Nodes::EnumTypeExtension.new(name, directives, enum_values_definition)
81
+ end
82
+
83
+ def union_type_extension
84
+ expect_token :UNION
85
+ name = self.name
86
+ directives = if at?(:DIR_SIGN); self.directives; end
87
+ union_member_types = if at?(:EQUALS); self.union_member_types; end
88
+ Nodes::UnionTypeExtension.new(name, directives, union_member_types)
89
+ end
90
+
91
+ def interface_type_extension
92
+ expect_token :INTERFACE
93
+ name = self.name
94
+ implements_interfaces = if at?(:IMPLEMENTS); self.implements_interfaces; end
95
+ directives = if at?(:DIR_SIGN); self.directives; end
96
+ fields_definition = if at?(:LCURLY); self.fields_definition; end
97
+ Nodes::InterfaceTypeExtension.new(name, implements_interfaces, directives, fields_definition)
98
+ end
99
+
100
+ def scalar_type_extension
101
+ expect_token :SCALAR
102
+ name = self.name
103
+ directives = if at?(:DIR_SIGN); self.directives; end
104
+ Nodes::ScalarTypeExtension.new(name, directives)
105
+ end
106
+
62
107
  def object_type_extension
63
108
  expect_token :TYPE
64
109
  name = self.name
@@ -128,7 +173,7 @@ module TinyGQL
128
173
  when :ENUM then enum_type_definition(desc)
129
174
  when :INPUT then input_object_type_definition(desc)
130
175
  else
131
- expect_token :FAIL
176
+ expect_token :TYPE
132
177
  end
133
178
  end
134
179
 
@@ -300,7 +345,7 @@ module TinyGQL
300
345
 
301
346
  def fragment_definition
302
347
  expect_token :FRAGMENT
303
- expect_token(:FAIL) if at?(:ON)
348
+ expect_token(:IDENTIFIER) if at?(:ON)
304
349
  name = self.name
305
350
  tc = self.type_condition
306
351
  directives = if at?(:DIR_SIGN)
@@ -353,15 +398,15 @@ module TinyGQL
353
398
  when :ON, :DIR_SIGN, :LCURLY then inline_fragment
354
399
  when :IDENTIFIER then fragment_spread
355
400
  else
356
- expect_token :FAIL
401
+ expect_token :IDENTIFIER
357
402
  end
358
403
  end
359
404
 
360
405
  def fragment_spread
361
406
  name = self.name
362
- directives = if at?(:DIR_SIGN)
363
- self.directives
364
- end
407
+ directives = if at?(:DIR_SIGN); self.directives; end
408
+
409
+ expect_token(:IDENTIFIER) if at?(:ON)
365
410
 
366
411
  Nodes::FragmentSpread.new(name, directives)
367
412
  end
@@ -477,7 +522,7 @@ module TinyGQL
477
522
  when :LCURLY then object_value
478
523
  when :VAR_SIGN then variable
479
524
  else
480
- expect_token :FAIL
525
+ expect_token :INT
481
526
  end
482
527
  end
483
528
 
@@ -1,3 +1,3 @@
1
1
  module TinyGQL
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end