graphql 1.7.14 → 1.8.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +5 -5
  2. data/lib/generators/graphql/function_generator.rb +1 -1
  3. data/lib/generators/graphql/loader_generator.rb +1 -1
  4. data/lib/generators/graphql/mutation_generator.rb +1 -6
  5. data/lib/generators/graphql/templates/function.erb +2 -2
  6. data/lib/generators/graphql/templates/loader.erb +2 -2
  7. data/lib/graphql.rb +2 -0
  8. data/lib/graphql/argument.rb +0 -1
  9. data/lib/graphql/backwards_compatibility.rb +2 -3
  10. data/lib/graphql/base_type.rb +18 -16
  11. data/lib/graphql/compatibility/query_parser_specification.rb +0 -117
  12. data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +0 -14
  13. data/lib/graphql/define/assign_object_field.rb +5 -12
  14. data/lib/graphql/deprecated_dsl.rb +28 -0
  15. data/lib/graphql/directive.rb +0 -1
  16. data/lib/graphql/enum_type.rb +1 -3
  17. data/lib/graphql/execution.rb +0 -1
  18. data/lib/graphql/execution/multiplex.rb +29 -12
  19. data/lib/graphql/field.rb +5 -20
  20. data/lib/graphql/function.rb +12 -0
  21. data/lib/graphql/input_object_type.rb +1 -3
  22. data/lib/graphql/internal_representation/node.rb +14 -26
  23. data/lib/graphql/internal_representation/visit.rb +6 -3
  24. data/lib/graphql/introspection/arguments_field.rb +0 -1
  25. data/lib/graphql/introspection/enum_values_field.rb +0 -1
  26. data/lib/graphql/introspection/fields_field.rb +0 -1
  27. data/lib/graphql/introspection/input_fields_field.rb +0 -1
  28. data/lib/graphql/introspection/interfaces_field.rb +0 -1
  29. data/lib/graphql/introspection/of_type_field.rb +0 -1
  30. data/lib/graphql/introspection/possible_types_field.rb +0 -1
  31. data/lib/graphql/introspection/schema_field.rb +0 -1
  32. data/lib/graphql/introspection/type_by_name_field.rb +0 -1
  33. data/lib/graphql/introspection/typename_field.rb +0 -1
  34. data/lib/graphql/language.rb +0 -3
  35. data/lib/graphql/language/generation.rb +182 -3
  36. data/lib/graphql/language/lexer.rb +69 -144
  37. data/lib/graphql/language/lexer.rl +4 -15
  38. data/lib/graphql/language/nodes.rb +76 -136
  39. data/lib/graphql/language/parser.rb +621 -668
  40. data/lib/graphql/language/parser.y +11 -17
  41. data/lib/graphql/language/token.rb +3 -10
  42. data/lib/graphql/object_type.rb +6 -1
  43. data/lib/graphql/query.rb +13 -8
  44. data/lib/graphql/query/arguments.rb +33 -48
  45. data/lib/graphql/query/context.rb +1 -0
  46. data/lib/graphql/query/literal_input.rb +1 -4
  47. data/lib/graphql/relay/connection_resolve.rb +3 -0
  48. data/lib/graphql/relay/global_id_resolve.rb +5 -1
  49. data/lib/graphql/relay/relation_connection.rb +19 -14
  50. data/lib/graphql/schema.rb +219 -12
  51. data/lib/graphql/schema/argument.rb +33 -0
  52. data/lib/graphql/schema/build_from_definition.rb +18 -64
  53. data/lib/graphql/schema/enum.rb +76 -0
  54. data/lib/graphql/schema/field.rb +127 -0
  55. data/lib/graphql/schema/field/dynamic_resolve.rb +63 -0
  56. data/lib/graphql/schema/field/unwrapped_resolve.rb +20 -0
  57. data/lib/graphql/schema/input_object.rb +61 -0
  58. data/lib/graphql/schema/interface.rb +32 -0
  59. data/lib/graphql/schema/loader.rb +2 -2
  60. data/lib/graphql/schema/member.rb +97 -0
  61. data/lib/graphql/schema/member/build_type.rb +106 -0
  62. data/lib/graphql/schema/member/has_fields.rb +56 -0
  63. data/lib/graphql/schema/member/instrumentation.rb +113 -0
  64. data/lib/graphql/schema/member/list_type_proxy.rb +21 -0
  65. data/lib/graphql/schema/member/non_null_type_proxy.rb +21 -0
  66. data/lib/graphql/schema/object.rb +65 -0
  67. data/lib/graphql/schema/printer.rb +266 -33
  68. data/lib/graphql/schema/scalar.rb +25 -0
  69. data/lib/graphql/schema/traversal.rb +26 -17
  70. data/lib/graphql/schema/union.rb +48 -0
  71. data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +1 -5
  72. data/lib/graphql/static_validation/rules/fields_will_merge.rb +8 -15
  73. data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +1 -11
  74. data/lib/graphql/subscriptions/action_cable_subscriptions.rb +5 -7
  75. data/lib/graphql/tracing.rb +0 -1
  76. data/lib/graphql/tracing/platform_tracing.rb +7 -20
  77. data/lib/graphql/tracing/scout_tracing.rb +2 -2
  78. data/lib/graphql/unresolved_type_error.rb +2 -3
  79. data/lib/graphql/version.rb +1 -1
  80. data/readme.md +1 -1
  81. data/spec/dummy/app/channels/graphql_channel.rb +1 -22
  82. data/spec/dummy/log/development.log +0 -239
  83. data/spec/dummy/log/test.log +0 -204
  84. data/spec/dummy/test/system/action_cable_subscription_test.rb +0 -4
  85. data/spec/dummy/tmp/screenshots/failures_test_it_handles_subscriptions.png +0 -0
  86. data/spec/generators/graphql/function_generator_spec.rb +0 -26
  87. data/spec/generators/graphql/loader_generator_spec.rb +0 -24
  88. data/spec/graphql/analysis/max_query_complexity_spec.rb +3 -3
  89. data/spec/graphql/analysis/max_query_depth_spec.rb +3 -3
  90. data/spec/graphql/backtrace_spec.rb +0 -10
  91. data/spec/graphql/base_type_spec.rb +5 -19
  92. data/spec/graphql/boolean_type_spec.rb +3 -3
  93. data/spec/graphql/directive_spec.rb +1 -3
  94. data/spec/graphql/enum_type_spec.rb +5 -18
  95. data/spec/graphql/execution/execute_spec.rb +1 -1
  96. data/spec/graphql/execution/multiplex_spec.rb +2 -2
  97. data/spec/graphql/float_type_spec.rb +2 -2
  98. data/spec/graphql/id_type_spec.rb +1 -1
  99. data/spec/graphql/input_object_type_spec.rb +2 -15
  100. data/spec/graphql/int_type_spec.rb +2 -2
  101. data/spec/graphql/internal_representation/rewrite_spec.rb +2 -2
  102. data/spec/graphql/introspection/schema_type_spec.rb +0 -1
  103. data/spec/graphql/language/generation_spec.rb +186 -21
  104. data/spec/graphql/language/lexer_spec.rb +1 -21
  105. data/spec/graphql/language/nodes_spec.rb +12 -21
  106. data/spec/graphql/language/parser_spec.rb +1 -1
  107. data/spec/graphql/query/arguments_spec.rb +15 -37
  108. data/spec/graphql/query/serial_execution/value_resolution_spec.rb +2 -2
  109. data/spec/graphql/query/variables_spec.rb +1 -1
  110. data/spec/graphql/query_spec.rb +5 -31
  111. data/spec/graphql/rake_task_spec.rb +1 -3
  112. data/spec/graphql/relay/base_connection_spec.rb +1 -1
  113. data/spec/graphql/relay/connection_instrumentation_spec.rb +2 -2
  114. data/spec/graphql/relay/connection_resolve_spec.rb +1 -1
  115. data/spec/graphql/relay/connection_type_spec.rb +1 -1
  116. data/spec/graphql/relay/mutation_spec.rb +3 -3
  117. data/spec/graphql/relay/relation_connection_spec.rb +1 -65
  118. data/spec/graphql/schema/build_from_definition_spec.rb +4 -86
  119. data/spec/graphql/schema/enum_spec.rb +60 -0
  120. data/spec/graphql/schema/field_spec.rb +14 -0
  121. data/spec/graphql/schema/input_object_spec.rb +43 -0
  122. data/spec/graphql/schema/interface_spec.rb +98 -0
  123. data/spec/graphql/schema/object_spec.rb +119 -0
  124. data/spec/graphql/schema/printer_spec.rb +15 -92
  125. data/spec/graphql/schema/scalar_spec.rb +40 -0
  126. data/spec/graphql/schema/union_spec.rb +35 -0
  127. data/spec/graphql/schema/validation_spec.rb +1 -1
  128. data/spec/graphql/schema/warden_spec.rb +11 -11
  129. data/spec/graphql/schema_spec.rb +25 -23
  130. data/spec/graphql/static_validation/rules/fields_have_appropriate_selections_spec.rb +2 -10
  131. data/spec/graphql/static_validation/rules/fields_will_merge_spec.rb +2 -2
  132. data/spec/graphql/string_type_spec.rb +3 -3
  133. data/spec/graphql/subscriptions_spec.rb +1 -1
  134. data/spec/graphql/tracing/platform_tracing_spec.rb +1 -60
  135. data/spec/support/dummy/schema.rb +25 -39
  136. data/spec/support/jazz.rb +334 -0
  137. data/spec/support/lazy_helpers.rb +21 -23
  138. data/spec/support/star_wars/data.rb +7 -6
  139. data/spec/support/star_wars/schema.rb +109 -142
  140. metadata +39 -33
  141. data/lib/graphql/execution/instrumentation.rb +0 -82
  142. data/lib/graphql/language/block_string.rb +0 -47
  143. data/lib/graphql/language/document_from_schema_definition.rb +0 -277
  144. data/lib/graphql/language/printer.rb +0 -351
  145. data/lib/graphql/tracing/data_dog_tracing.rb +0 -49
  146. data/spec/graphql/execution/instrumentation_spec.rb +0 -165
  147. data/spec/graphql/language/block_string_spec.rb +0 -70
  148. data/spec/graphql/language/document_from_schema_definition_spec.rb +0 -770
  149. data/spec/graphql/language/printer_spec.rb +0 -203
@@ -1,203 +0,0 @@
1
- # frozen_string_literal: true
2
- require "spec_helper"
3
-
4
- describe GraphQL::Language::Printer do
5
- let(:document) { GraphQL::Language::Parser.parse(query_string) }
6
- let(:query_string) {%|
7
- query getStuff($someVar: Int = 1, $anotherVar: [String!], $skipNested: Boolean! = false) @skip(if: false) {
8
- myField: someField(someArg: $someVar, ok: 1.4) @skip(if: $anotherVar) @thing(or: "Whatever")
9
- anotherField(someArg: [1, 2, 3]) {
10
- nestedField
11
- ...moreNestedFields @skip(if: $skipNested)
12
- }
13
- ... on OtherType @include(unless: false) {
14
- field(arg: [{key: "value", anotherKey: 0.9, anotherAnotherKey: WHATEVER}])
15
- anotherField
16
- }
17
- ... {
18
- id
19
- }
20
- }
21
-
22
- fragment moreNestedFields on NestedType @or(something: "ok") {
23
- anotherNestedField
24
- }
25
- |}
26
-
27
- let(:printer) { GraphQL::Language::Printer.new }
28
-
29
- describe "#print" do
30
- it "prints the query string" do
31
- assert_equal query_string.gsub(/^ /, "").strip, printer.print(document)
32
- end
33
-
34
- describe "inputs" do
35
- let(:query_string) {%|
36
- query {
37
- field(null_value: null, null_in_array: [1, null, 3], int: 3, float: 4.7e-24, bool: false, string: "☀︎🏆\\n escaped \\" unicode ¶ /", enum: ENUM_NAME, array: [7, 8, 9], object: {a: [1, 2, 3], b: {c: "4"}}, unicode_bom: "\xef\xbb\xbfquery")
38
- }
39
- |}
40
-
41
- it "prints the query string" do
42
- assert_equal query_string.gsub(/^ /, "").strip, printer.print(document)
43
- end
44
- end
45
-
46
- describe "schema" do
47
- describe "schema with convention names for root types" do
48
- let(:query_string) {<<-schema
49
- schema {
50
- query: Query
51
- mutation: Mutation
52
- subscription: Subscription
53
- }
54
- schema
55
- }
56
-
57
- it 'omits schema definition' do
58
- refute printer.print(document) =~ /schema/
59
- end
60
- end
61
-
62
- describe "schema with custom query root name" do
63
- let(:query_string) {<<-schema
64
- schema {
65
- query: MyQuery
66
- mutation: Mutation
67
- subscription: Subscription
68
- }
69
- schema
70
- }
71
-
72
- it 'includes schema definition' do
73
- assert_equal query_string.gsub(/^ /, "").strip, printer.print(document)
74
- end
75
- end
76
-
77
- describe "schema with custom mutation root name" do
78
- let(:query_string) {<<-schema
79
- schema {
80
- query: Query
81
- mutation: MyMutation
82
- subscription: Subscription
83
- }
84
- schema
85
- }
86
-
87
- it 'includes schema definition' do
88
- assert_equal query_string.gsub(/^ /, "").strip, printer.print(document)
89
- end
90
- end
91
-
92
- describe "schema with custom subscription root name" do
93
- let(:query_string) {<<-schema
94
- schema {
95
- query: Query
96
- mutation: Mutation
97
- subscription: MySubscription
98
- }
99
- schema
100
- }
101
-
102
- it 'includes schema definition' do
103
- assert_equal query_string.gsub(/^ /, "").strip, printer.print(document)
104
- end
105
- end
106
-
107
- describe "full featured schema" do
108
- # Based on: https://github.com/graphql/graphql-js/blob/bc96406ab44453a120da25a0bd6e2b0237119ddf/src/language/__tests__/schema-kitchen-sink.graphql
109
- let(:query_string) {<<-schema
110
- schema {
111
- query: QueryType
112
- mutation: MutationType
113
- }
114
-
115
- # Union description
116
- union AnnotatedUnion @onUnion = A | B
117
-
118
- type Foo implements Bar & AnnotatedInterface {
119
- one: Type
120
- two(argument: InputType!): Type
121
- three(argument: InputType, other: String): Int
122
- four(argument: String = "string"): String
123
- five(argument: [String] = ["string", "string"]): String
124
- six(argument: InputType = {key: "value"}): Type
125
- seven(argument: String = null): Type
126
- }
127
-
128
- # Scalar description
129
- scalar CustomScalar
130
-
131
- type AnnotatedObject implements Bar @onObject(arg: "value") {
132
- annotatedField(arg: Type = "default" @onArg): Type @onField
133
- }
134
-
135
- interface Bar {
136
- one: Type
137
- four(argument: String = "string"): String
138
- }
139
-
140
- # Enum description
141
- enum Site {
142
- # Enum value description
143
- DESKTOP
144
- MOBILE
145
- }
146
-
147
- interface AnnotatedInterface @onInterface {
148
- annotatedField(arg: Type @onArg): Type @onField
149
- }
150
-
151
- union Feed = Story | Article | Advert
152
-
153
- # Input description
154
- input InputType {
155
- key: String!
156
- answer: Int = 42
157
- }
158
-
159
- union AnnotatedUnion @onUnion = A | B
160
-
161
- scalar CustomScalar
162
-
163
- # Directive description
164
- directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
165
-
166
- scalar AnnotatedScalar @onScalar
167
-
168
- enum Site {
169
- DESKTOP
170
- MOBILE
171
- }
172
-
173
- enum AnnotatedEnum @onEnum {
174
- ANNOTATED_VALUE @onEnumValue
175
- OTHER_VALUE
176
- }
177
-
178
- input InputType {
179
- key: String!
180
- answer: Int = 42
181
- }
182
-
183
- input AnnotatedInput @onInputObjectType {
184
- annotatedField: Type @onField
185
- }
186
-
187
- directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
188
-
189
- directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
190
- schema
191
- }
192
-
193
- it "generate" do
194
- assert_equal query_string.gsub(/^ /, "").strip, printer.print(document)
195
- end
196
-
197
- it "doesn't mutate the document" do
198
- assert_equal printer.print(document), printer.print(document)
199
- end
200
- end
201
- end
202
- end
203
- end