graphql 1.9.11 → 1.9.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (286) hide show
  1. checksums.yaml +4 -4
  2. data/lib/graphql/analysis/ast/query_complexity.rb +0 -8
  3. data/lib/graphql/analysis/ast/query_depth.rb +0 -8
  4. data/lib/graphql/analysis/ast/visitor.rb +26 -24
  5. data/lib/graphql/execution.rb +1 -0
  6. data/lib/graphql/execution/errors.rb +60 -0
  7. data/lib/graphql/execution/interpreter/runtime.rb +21 -17
  8. data/lib/graphql/static_validation/rules/fields_will_merge.rb +15 -8
  9. data/lib/graphql/version.rb +1 -1
  10. metadata +5 -556
  11. data/spec/dummy/Gemfile +0 -12
  12. data/spec/dummy/README.md +0 -24
  13. data/spec/dummy/Rakefile +0 -7
  14. data/spec/dummy/app/assets/config/manifest.js +0 -1
  15. data/spec/dummy/app/assets/javascripts/application.js +0 -66
  16. data/spec/dummy/app/channels/application_cable/channel.rb +0 -5
  17. data/spec/dummy/app/channels/application_cable/connection.rb +0 -5
  18. data/spec/dummy/app/channels/graphql_channel.rb +0 -116
  19. data/spec/dummy/app/controllers/application_controller.rb +0 -4
  20. data/spec/dummy/app/controllers/pages_controller.rb +0 -5
  21. data/spec/dummy/app/helpers/application_helper.rb +0 -3
  22. data/spec/dummy/app/jobs/application_job.rb +0 -3
  23. data/spec/dummy/app/views/layouts/application.html.erb +0 -12
  24. data/spec/dummy/app/views/pages/show.html +0 -16
  25. data/spec/dummy/bin/bundle +0 -4
  26. data/spec/dummy/bin/rails +0 -5
  27. data/spec/dummy/bin/rake +0 -5
  28. data/spec/dummy/bin/setup +0 -31
  29. data/spec/dummy/bin/update +0 -27
  30. data/spec/dummy/bin/yarn +0 -12
  31. data/spec/dummy/config.ru +0 -6
  32. data/spec/dummy/config/application.rb +0 -30
  33. data/spec/dummy/config/boot.rb +0 -4
  34. data/spec/dummy/config/cable.yml +0 -10
  35. data/spec/dummy/config/environment.rb +0 -6
  36. data/spec/dummy/config/environments/development.rb +0 -40
  37. data/spec/dummy/config/environments/production.rb +0 -76
  38. data/spec/dummy/config/environments/test.rb +0 -37
  39. data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -9
  40. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -8
  41. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -6
  42. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -5
  43. data/spec/dummy/config/initializers/inflections.rb +0 -17
  44. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  45. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -10
  46. data/spec/dummy/config/locales/en.yml +0 -33
  47. data/spec/dummy/config/puma.rb +0 -57
  48. data/spec/dummy/config/routes.rb +0 -4
  49. data/spec/dummy/config/secrets.yml +0 -32
  50. data/spec/dummy/package.json +0 -5
  51. data/spec/dummy/public/404.html +0 -67
  52. data/spec/dummy/public/422.html +0 -67
  53. data/spec/dummy/public/500.html +0 -66
  54. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  55. data/spec/dummy/public/apple-touch-icon.png +0 -0
  56. data/spec/dummy/public/favicon.ico +0 -0
  57. data/spec/dummy/public/robots.txt +0 -1
  58. data/spec/dummy/test/application_system_test_case.rb +0 -6
  59. data/spec/dummy/test/system/action_cable_subscription_test.rb +0 -45
  60. data/spec/dummy/test/test_helper.rb +0 -4
  61. data/spec/fixtures/upgrader/account.original.rb +0 -19
  62. data/spec/fixtures/upgrader/account.transformed.rb +0 -20
  63. data/spec/fixtures/upgrader/blame_range.original.rb +0 -43
  64. data/spec/fixtures/upgrader/blame_range.transformed.rb +0 -30
  65. data/spec/fixtures/upgrader/date_time.original.rb +0 -24
  66. data/spec/fixtures/upgrader/date_time.transformed.rb +0 -23
  67. data/spec/fixtures/upgrader/delete_project.original.rb +0 -28
  68. data/spec/fixtures/upgrader/delete_project.transformed.rb +0 -27
  69. data/spec/fixtures/upgrader/gist_order_field.original.rb +0 -14
  70. data/spec/fixtures/upgrader/gist_order_field.transformed.rb +0 -13
  71. data/spec/fixtures/upgrader/increment_count.original.rb +0 -59
  72. data/spec/fixtures/upgrader/increment_count.transformed.rb +0 -50
  73. data/spec/fixtures/upgrader/mutation.original.rb +0 -28
  74. data/spec/fixtures/upgrader/mutation.transformed.rb +0 -28
  75. data/spec/fixtures/upgrader/photo.original.rb +0 -10
  76. data/spec/fixtures/upgrader/photo.transformed.rb +0 -12
  77. data/spec/fixtures/upgrader/release_order.original.rb +0 -15
  78. data/spec/fixtures/upgrader/release_order.transformed.rb +0 -14
  79. data/spec/fixtures/upgrader/starrable.original.rb +0 -49
  80. data/spec/fixtures/upgrader/starrable.transformed.rb +0 -46
  81. data/spec/fixtures/upgrader/subscribable.original.rb +0 -55
  82. data/spec/fixtures/upgrader/subscribable.transformed.rb +0 -51
  83. data/spec/fixtures/upgrader/type_x.original.rb +0 -65
  84. data/spec/fixtures/upgrader/type_x.transformed.rb +0 -56
  85. data/spec/graphql/analysis/analyze_query_spec.rb +0 -261
  86. data/spec/graphql/analysis/ast/field_usage_spec.rb +0 -51
  87. data/spec/graphql/analysis/ast/max_query_complexity_spec.rb +0 -120
  88. data/spec/graphql/analysis/ast/max_query_depth_spec.rb +0 -134
  89. data/spec/graphql/analysis/ast/query_complexity_spec.rb +0 -299
  90. data/spec/graphql/analysis/ast/query_depth_spec.rb +0 -108
  91. data/spec/graphql/analysis/ast_spec.rb +0 -296
  92. data/spec/graphql/analysis/field_usage_spec.rb +0 -62
  93. data/spec/graphql/analysis/max_query_complexity_spec.rb +0 -102
  94. data/spec/graphql/analysis/max_query_depth_spec.rb +0 -103
  95. data/spec/graphql/analysis/query_complexity_spec.rb +0 -301
  96. data/spec/graphql/analysis/query_depth_spec.rb +0 -81
  97. data/spec/graphql/argument_spec.rb +0 -159
  98. data/spec/graphql/authorization_spec.rb +0 -974
  99. data/spec/graphql/backtrace_spec.rb +0 -206
  100. data/spec/graphql/base_type_spec.rb +0 -171
  101. data/spec/graphql/boolean_type_spec.rb +0 -21
  102. data/spec/graphql/compatibility/execution_specification_spec.rb +0 -4
  103. data/spec/graphql/compatibility/lazy_execution_specification_spec.rb +0 -4
  104. data/spec/graphql/compatibility/query_parser_specification_spec.rb +0 -6
  105. data/spec/graphql/compatibility/schema_parser_specification_spec.rb +0 -6
  106. data/spec/graphql/define/assign_argument_spec.rb +0 -61
  107. data/spec/graphql/define/instance_definable_spec.rb +0 -203
  108. data/spec/graphql/directive/skip_directive_spec.rb +0 -9
  109. data/spec/graphql/directive_spec.rb +0 -295
  110. data/spec/graphql/enum_type_spec.rb +0 -158
  111. data/spec/graphql/execution/execute_spec.rb +0 -303
  112. data/spec/graphql/execution/instrumentation_spec.rb +0 -212
  113. data/spec/graphql/execution/interpreter_spec.rb +0 -485
  114. data/spec/graphql/execution/lazy/lazy_method_map_spec.rb +0 -57
  115. data/spec/graphql/execution/lazy_spec.rb +0 -247
  116. data/spec/graphql/execution/lookahead_spec.rb +0 -390
  117. data/spec/graphql/execution/multiplex_spec.rb +0 -222
  118. data/spec/graphql/execution/typecast_spec.rb +0 -47
  119. data/spec/graphql/execution_error_spec.rb +0 -329
  120. data/spec/graphql/field_spec.rb +0 -246
  121. data/spec/graphql/float_type_spec.rb +0 -16
  122. data/spec/graphql/function_spec.rb +0 -152
  123. data/spec/graphql/id_type_spec.rb +0 -33
  124. data/spec/graphql/input_object_type_spec.rb +0 -25
  125. data/spec/graphql/int_type_spec.rb +0 -35
  126. data/spec/graphql/interface_type_spec.rb +0 -196
  127. data/spec/graphql/internal_representation/print_spec.rb +0 -41
  128. data/spec/graphql/internal_representation/rewrite_spec.rb +0 -381
  129. data/spec/graphql/introspection/directive_type_spec.rb +0 -66
  130. data/spec/graphql/introspection/input_value_type_spec.rb +0 -144
  131. data/spec/graphql/introspection/introspection_query_spec.rb +0 -64
  132. data/spec/graphql/introspection/schema_type_spec.rb +0 -57
  133. data/spec/graphql/introspection/type_type_spec.rb +0 -155
  134. data/spec/graphql/language/block_string_spec.rb +0 -70
  135. data/spec/graphql/language/definition_slice_spec.rb +0 -226
  136. data/spec/graphql/language/document_from_schema_definition_spec.rb +0 -770
  137. data/spec/graphql/language/equality_spec.rb +0 -84
  138. data/spec/graphql/language/generation_spec.rb +0 -38
  139. data/spec/graphql/language/lexer_spec.rb +0 -153
  140. data/spec/graphql/language/nodes_spec.rb +0 -67
  141. data/spec/graphql/language/parser_spec.rb +0 -183
  142. data/spec/graphql/language/printer_spec.rb +0 -215
  143. data/spec/graphql/language/visitor_spec.rb +0 -419
  144. data/spec/graphql/list_type_spec.rb +0 -57
  145. data/spec/graphql/non_null_type_spec.rb +0 -48
  146. data/spec/graphql/object_type_spec.rb +0 -197
  147. data/spec/graphql/query/arguments_spec.rb +0 -346
  148. data/spec/graphql/query/context_spec.rb +0 -292
  149. data/spec/graphql/query/executor_spec.rb +0 -341
  150. data/spec/graphql/query/literal_input_spec.rb +0 -91
  151. data/spec/graphql/query/result_spec.rb +0 -29
  152. data/spec/graphql/query/serial_execution/value_resolution_spec.rb +0 -109
  153. data/spec/graphql/query_spec.rb +0 -803
  154. data/spec/graphql/rake_task_spec.rb +0 -59
  155. data/spec/graphql/scalar_type_spec.rb +0 -66
  156. data/spec/graphql/schema/argument_spec.rb +0 -186
  157. data/spec/graphql/schema/build_from_definition_spec.rb +0 -1197
  158. data/spec/graphql/schema/catchall_middleware_spec.rb +0 -32
  159. data/spec/graphql/schema/directive/feature_spec.rb +0 -81
  160. data/spec/graphql/schema/directive/transform_spec.rb +0 -39
  161. data/spec/graphql/schema/enum_spec.rb +0 -83
  162. data/spec/graphql/schema/enum_value_spec.rb +0 -24
  163. data/spec/graphql/schema/field_extension_spec.rb +0 -159
  164. data/spec/graphql/schema/field_spec.rb +0 -319
  165. data/spec/graphql/schema/finder_spec.rb +0 -135
  166. data/spec/graphql/schema/input_object_spec.rb +0 -421
  167. data/spec/graphql/schema/instrumentation_spec.rb +0 -43
  168. data/spec/graphql/schema/interface_spec.rb +0 -215
  169. data/spec/graphql/schema/introspection_system_spec.rb +0 -80
  170. data/spec/graphql/schema/list_spec.rb +0 -73
  171. data/spec/graphql/schema/loader_spec.rb +0 -350
  172. data/spec/graphql/schema/member/accepts_definition_spec.rb +0 -115
  173. data/spec/graphql/schema/member/build_type_spec.rb +0 -63
  174. data/spec/graphql/schema/member/scoped_spec.rb +0 -217
  175. data/spec/graphql/schema/member/type_system_helpers_spec.rb +0 -63
  176. data/spec/graphql/schema/middleware_chain_spec.rb +0 -57
  177. data/spec/graphql/schema/mutation_spec.rb +0 -150
  178. data/spec/graphql/schema/non_null_spec.rb +0 -46
  179. data/spec/graphql/schema/object_spec.rb +0 -355
  180. data/spec/graphql/schema/printer_spec.rb +0 -883
  181. data/spec/graphql/schema/relay_classic_mutation_spec.rb +0 -252
  182. data/spec/graphql/schema/rescue_middleware_spec.rb +0 -88
  183. data/spec/graphql/schema/resolver_spec.rb +0 -743
  184. data/spec/graphql/schema/scalar_spec.rb +0 -101
  185. data/spec/graphql/schema/subscription_spec.rb +0 -505
  186. data/spec/graphql/schema/timeout_middleware_spec.rb +0 -188
  187. data/spec/graphql/schema/timeout_spec.rb +0 -206
  188. data/spec/graphql/schema/traversal_spec.rb +0 -222
  189. data/spec/graphql/schema/type_expression_spec.rb +0 -39
  190. data/spec/graphql/schema/union_spec.rb +0 -72
  191. data/spec/graphql/schema/unique_within_type_spec.rb +0 -44
  192. data/spec/graphql/schema/validation_spec.rb +0 -355
  193. data/spec/graphql/schema/warden_spec.rb +0 -926
  194. data/spec/graphql/schema_spec.rb +0 -169
  195. data/spec/graphql/static_validation/rules/argument_literals_are_compatible_spec.rb +0 -466
  196. data/spec/graphql/static_validation/rules/argument_names_are_unique_spec.rb +0 -44
  197. data/spec/graphql/static_validation/rules/arguments_are_defined_spec.rb +0 -112
  198. data/spec/graphql/static_validation/rules/directives_are_defined_spec.rb +0 -35
  199. data/spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb +0 -42
  200. data/spec/graphql/static_validation/rules/fields_are_defined_on_type_spec.rb +0 -167
  201. data/spec/graphql/static_validation/rules/fields_have_appropriate_selections_spec.rb +0 -66
  202. data/spec/graphql/static_validation/rules/fields_will_merge_spec.rb +0 -740
  203. data/spec/graphql/static_validation/rules/fragment_names_are_unique_spec.rb +0 -28
  204. data/spec/graphql/static_validation/rules/fragment_spreads_are_possible_spec.rb +0 -52
  205. data/spec/graphql/static_validation/rules/fragment_types_exist_spec.rb +0 -42
  206. data/spec/graphql/static_validation/rules/fragments_are_finite_spec.rb +0 -123
  207. data/spec/graphql/static_validation/rules/fragments_are_named_spec.rb +0 -24
  208. data/spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb +0 -56
  209. data/spec/graphql/static_validation/rules/fragments_are_used_spec.rb +0 -61
  210. data/spec/graphql/static_validation/rules/mutation_root_exists_spec.rb +0 -39
  211. data/spec/graphql/static_validation/rules/no_definitions_are_present_spec.rb +0 -62
  212. data/spec/graphql/static_validation/rules/operation_names_are_valid_spec.rb +0 -82
  213. data/spec/graphql/static_validation/rules/required_arguments_are_present_spec.rb +0 -98
  214. data/spec/graphql/static_validation/rules/required_input_object_attributes_are_present_spec.rb +0 -86
  215. data/spec/graphql/static_validation/rules/subscription_root_exists_spec.rb +0 -34
  216. data/spec/graphql/static_validation/rules/unique_directives_per_location_spec.rb +0 -188
  217. data/spec/graphql/static_validation/rules/variable_default_values_are_correctly_typed_spec.rb +0 -196
  218. data/spec/graphql/static_validation/rules/variable_names_are_unique_spec.rb +0 -23
  219. data/spec/graphql/static_validation/rules/variable_usages_are_allowed_spec.rb +0 -236
  220. data/spec/graphql/static_validation/rules/variables_are_input_types_spec.rb +0 -78
  221. data/spec/graphql/static_validation/rules/variables_are_used_and_defined_spec.rb +0 -81
  222. data/spec/graphql/static_validation/type_stack_spec.rb +0 -29
  223. data/spec/graphql/static_validation/validator_spec.rb +0 -204
  224. data/spec/graphql/string_type_spec.rb +0 -80
  225. data/spec/graphql/subscriptions/serialize_spec.rb +0 -49
  226. data/spec/graphql/subscriptions_spec.rb +0 -540
  227. data/spec/graphql/tracing/new_relic_tracing_spec.rb +0 -84
  228. data/spec/graphql/tracing/platform_tracing_spec.rb +0 -141
  229. data/spec/graphql/tracing/prometheus_tracing_spec.rb +0 -42
  230. data/spec/graphql/tracing/scout_tracing_spec.rb +0 -17
  231. data/spec/graphql/tracing/skylight_tracing_spec.rb +0 -63
  232. data/spec/graphql/tracing_spec.rb +0 -52
  233. data/spec/graphql/types/big_int_spec.rb +0 -24
  234. data/spec/graphql/types/iso_8601_date_time_spec.rb +0 -137
  235. data/spec/graphql/types/relay/base_edge_spec.rb +0 -33
  236. data/spec/graphql/union_type_spec.rb +0 -211
  237. data/spec/graphql/upgrader/member_spec.rb +0 -583
  238. data/spec/graphql/upgrader/schema_spec.rb +0 -82
  239. data/spec/integration/mongoid/graphql/relay/mongo_relation_connection_spec.rb +0 -528
  240. data/spec/integration/mongoid/spec_helper.rb +0 -2
  241. data/spec/integration/mongoid/star_trek/data.rb +0 -126
  242. data/spec/integration/mongoid/star_trek/schema.rb +0 -424
  243. data/spec/integration/rails/data.rb +0 -110
  244. data/spec/integration/rails/generators/base_generator_test.rb +0 -7
  245. data/spec/integration/rails/generators/graphql/enum_generator_spec.rb +0 -30
  246. data/spec/integration/rails/generators/graphql/install_generator_spec.rb +0 -238
  247. data/spec/integration/rails/generators/graphql/interface_generator_spec.rb +0 -34
  248. data/spec/integration/rails/generators/graphql/loader_generator_spec.rb +0 -59
  249. data/spec/integration/rails/generators/graphql/mutation_generator_spec.rb +0 -71
  250. data/spec/integration/rails/generators/graphql/object_generator_spec.rb +0 -54
  251. data/spec/integration/rails/generators/graphql/scalar_generator_spec.rb +0 -28
  252. data/spec/integration/rails/generators/graphql/union_generator_spec.rb +0 -67
  253. data/spec/integration/rails/graphql/input_object_spec.rb +0 -19
  254. data/spec/integration/rails/graphql/input_object_type_spec.rb +0 -364
  255. data/spec/integration/rails/graphql/query/variables_spec.rb +0 -375
  256. data/spec/integration/rails/graphql/relay/array_connection_spec.rb +0 -309
  257. data/spec/integration/rails/graphql/relay/base_connection_spec.rb +0 -101
  258. data/spec/integration/rails/graphql/relay/connection_instrumentation_spec.rb +0 -80
  259. data/spec/integration/rails/graphql/relay/connection_resolve_spec.rb +0 -79
  260. data/spec/integration/rails/graphql/relay/connection_type_spec.rb +0 -106
  261. data/spec/integration/rails/graphql/relay/edge_spec.rb +0 -10
  262. data/spec/integration/rails/graphql/relay/mutation_spec.rb +0 -387
  263. data/spec/integration/rails/graphql/relay/node_spec.rb +0 -263
  264. data/spec/integration/rails/graphql/relay/page_info_spec.rb +0 -111
  265. data/spec/integration/rails/graphql/relay/range_add_spec.rb +0 -117
  266. data/spec/integration/rails/graphql/relay/relation_connection_spec.rb +0 -837
  267. data/spec/integration/rails/graphql/schema_spec.rb +0 -507
  268. data/spec/integration/rails/graphql/tracing/active_support_notifications_tracing_spec.rb +0 -62
  269. data/spec/integration/rails/spec_helper.rb +0 -25
  270. data/spec/spec_helper.rb +0 -116
  271. data/spec/support/dummy/data.rb +0 -45
  272. data/spec/support/dummy/schema.rb +0 -519
  273. data/spec/support/error_bubbling_helpers.rb +0 -23
  274. data/spec/support/global_id.rb +0 -23
  275. data/spec/support/jazz.rb +0 -778
  276. data/spec/support/lazy_helpers.rb +0 -192
  277. data/spec/support/magic_cards/schema.graphql +0 -33
  278. data/spec/support/minimum_input_object.rb +0 -21
  279. data/spec/support/new_relic.rb +0 -27
  280. data/spec/support/parser/filename_example.graphql +0 -5
  281. data/spec/support/parser/filename_example_error_1.graphql +0 -4
  282. data/spec/support/parser/filename_example_error_2.graphql +0 -5
  283. data/spec/support/parser/filename_example_invalid_utf8.graphql +0 -1
  284. data/spec/support/skylight.rb +0 -39
  285. data/spec/support/star_wars/schema.rb +0 -464
  286. data/spec/support/static_validation_helpers.rb +0 -32
@@ -1,84 +0,0 @@
1
- # frozen_string_literal: true
2
- require "spec_helper"
3
-
4
- describe GraphQL::Tracing::NewRelicTracing do
5
- module NewRelicTest
6
- class Thing < GraphQL::Schema::Object
7
- implements GraphQL::Types::Relay::Node
8
- end
9
-
10
- class Query < GraphQL::Schema::Object
11
- add_field GraphQL::Types::Relay::NodeField
12
-
13
- field :int, Integer, null: false
14
-
15
- def int
16
- 1
17
- end
18
- end
19
-
20
- class SchemaWithoutTransactionName < GraphQL::Schema
21
- query(Query)
22
- use(GraphQL::Tracing::NewRelicTracing)
23
- orphan_types(Thing)
24
-
25
- def self.object_from_id(_id, _ctx)
26
- :thing
27
- end
28
-
29
- def self.resolve_type(_type, _obj, _ctx)
30
- Thing
31
- end
32
-
33
- if TESTING_INTERPRETER
34
- use GraphQL::Execution::Interpreter
35
- end
36
- end
37
-
38
- class SchemaWithTransactionName < GraphQL::Schema
39
- query(Query)
40
- use(GraphQL::Tracing::NewRelicTracing, set_transaction_name: true)
41
- if TESTING_INTERPRETER
42
- use GraphQL::Execution::Interpreter
43
- end
44
- end
45
-
46
- class SchemaWithScalarTrace < GraphQL::Schema
47
- query(Query)
48
- use(GraphQL::Tracing::NewRelicTracing, trace_scalars: true)
49
- end
50
- end
51
-
52
- before do
53
- NewRelic.clear_all
54
- end
55
-
56
- it "works with the built-in node field, even though it doesn't have an @owner" do
57
- res = NewRelicTest::SchemaWithoutTransactionName.execute '{ node(id: "1") { __typename } }'
58
- assert_equal "Thing", res["data"]["node"]["__typename"]
59
- end
60
-
61
- it "can leave the transaction name in place" do
62
- NewRelicTest::SchemaWithoutTransactionName.execute "query X { int }"
63
- assert_equal [], NewRelic::TRANSACTION_NAMES
64
- end
65
-
66
- it "can override the transaction name" do
67
- NewRelicTest::SchemaWithTransactionName.execute "query X { int }"
68
- assert_equal ["GraphQL/query.X"], NewRelic::TRANSACTION_NAMES
69
- end
70
-
71
- it "can override the transaction name per query" do
72
- # Override with `false`
73
- NewRelicTest::SchemaWithTransactionName.execute "{ int }", context: { set_new_relic_transaction_name: false }
74
- assert_equal [], NewRelic::TRANSACTION_NAMES
75
- # Override with `true`
76
- NewRelicTest::SchemaWithoutTransactionName.execute "{ int }", context: { set_new_relic_transaction_name: true }
77
- assert_equal ["GraphQL/query.anonymous"], NewRelic::TRANSACTION_NAMES
78
- end
79
-
80
- it "traces scalars when trace_scalars is true" do
81
- NewRelicTest::SchemaWithScalarTrace.execute "query X { int }"
82
- assert_includes NewRelic::EXECUTION_SCOPES, "GraphQL/Query/int"
83
- end
84
- end
@@ -1,141 +0,0 @@
1
- # frozen_string_literal: true
2
- require "spec_helper"
3
-
4
- describe GraphQL::Tracing::PlatformTracing do
5
- class CustomPlatformTracer < GraphQL::Tracing::PlatformTracing
6
- TRACE = []
7
-
8
- self.platform_keys = {
9
- "lex" => "l",
10
- "parse" => "p",
11
- "validate" => "v",
12
- "analyze_query" => "aq",
13
- "analyze_multiplex" => "am",
14
- "execute_multiplex" => "em",
15
- "execute_query" => "eq",
16
- "execute_query_lazy" => "eql",
17
- }
18
-
19
- def platform_field_key(type, field)
20
- "#{type.graphql_name[0]}.#{field.graphql_name[0]}"
21
- end
22
-
23
- def platform_trace(platform_key, key, data)
24
- TRACE << platform_key
25
- yield
26
- end
27
- end
28
-
29
- describe "calling a platform tracer" do
30
- let(:schema) {
31
- Dummy::Schema.redefine {
32
- use(CustomPlatformTracer)
33
- }
34
- }
35
-
36
- before do
37
- CustomPlatformTracer::TRACE.clear
38
- end
39
-
40
- it "runs the introspection query (handles late-bound types)" do
41
- assert schema.execute(GraphQL::Introspection::INTROSPECTION_QUERY)
42
- end
43
-
44
- it "calls the platform's own method with its own keys" do
45
- schema.execute(" { cheese(id: 1) { flavor } }")
46
- # This is different because schema/member/instrumentation
47
- # calls `irep_selection` which causes the query to be parsed.
48
- # But interpreter doesn't require parsing until later.
49
- expected_trace = if TESTING_INTERPRETER
50
- [
51
- "em",
52
- "am",
53
- "l",
54
- "p",
55
- "v",
56
- "aq",
57
- "eq",
58
- "Q.c", # notice that the flavor is skipped
59
- "eql",
60
- ]
61
- else
62
- ["em", "l", "p", "v", "am", "aq", "eq", "Q.c", "eql"]
63
- end
64
-
65
- assert_equal expected_trace, CustomPlatformTracer::TRACE
66
- end
67
- end
68
-
69
- describe "by default, scalar fields are not traced" do
70
- let(:schema) {
71
- Dummy::Schema.redefine {
72
- use(CustomPlatformTracer)
73
- }
74
- }
75
-
76
- before do
77
- CustomPlatformTracer::TRACE.clear
78
- end
79
-
80
- it "only traces traceTrue, not traceFalse or traceNil" do
81
- schema.execute(" { tracingScalar { traceNil traceFalse traceTrue } }")
82
- # This is different because schema/member/instrumentation
83
- # calls `irep_selection` which causes the query to be parsed.
84
- # But interpreter doesn't require parsing until later.
85
- expected_trace = if TESTING_INTERPRETER
86
- [
87
- "em",
88
- "am",
89
- "l",
90
- "p",
91
- "v",
92
- "aq",
93
- "eq",
94
- "Q.t",
95
- "T.t",
96
- "eql",
97
- ]
98
- else
99
- ["em", "l", "p", "v", "am", "aq", "eq", "Q.t", "T.t", "eql"]
100
- end
101
- assert_equal expected_trace, CustomPlatformTracer::TRACE
102
- end
103
- end
104
-
105
- describe "when scalar fields are traced by default, they are unless specified" do
106
- let(:schema) {
107
- Dummy::Schema.redefine {
108
- use(CustomPlatformTracer, trace_scalars: true)
109
- }
110
- }
111
-
112
- before do
113
- CustomPlatformTracer::TRACE.clear
114
- end
115
-
116
- it "traces traceTrue and traceNil but not traceFalse" do
117
- schema.execute(" { tracingScalar { traceNil traceFalse traceTrue } }")
118
- # This is different because schema/member/instrumentation
119
- # calls `irep_selection` which causes the query to be parsed.
120
- # But interpreter doesn't require parsing until later.
121
- expected_trace = if TESTING_INTERPRETER
122
- [
123
- "em",
124
- "am",
125
- "l",
126
- "p",
127
- "v",
128
- "aq",
129
- "eq",
130
- "Q.t",
131
- "T.t",
132
- "T.t",
133
- "eql",
134
- ]
135
- else
136
- ["em", "l", "p", "v", "am", "aq", "eq", "Q.t", "T.t", "T.t", "eql"]
137
- end
138
- assert_equal expected_trace, CustomPlatformTracer::TRACE
139
- end
140
- end
141
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- describe GraphQL::Tracing::PrometheusTracing do
6
- module PrometheusTracingTest
7
- class Query < GraphQL::Schema::Object
8
- field :int, Integer, null: false
9
-
10
- def int
11
- 1
12
- end
13
- end
14
-
15
- class Schema < GraphQL::Schema
16
- query Query
17
- if TESTING_INTERPRETER
18
- use GraphQL::Execution::Interpreter
19
- end
20
- end
21
- end
22
-
23
- describe "Observing" do
24
- it "sends JSON to Prometheus client" do
25
- client = Minitest::Mock.new
26
-
27
- client.expect :send_json, true do |obj|
28
- obj[:type] == 'graphql' &&
29
- obj[:key] == 'execute_field' &&
30
- obj[:platform_key] == 'Query.int'
31
- end
32
-
33
- PrometheusTracingTest::Schema.use(
34
- GraphQL::Tracing::PrometheusTracing,
35
- client: client,
36
- trace_scalars: true
37
- )
38
-
39
- PrometheusTracingTest::Schema.execute "query X { int }"
40
- end
41
- end
42
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- describe GraphQL::Tracing::ScoutTracing do
6
- class ScoutApm
7
- module Tracer
8
- end
9
- end
10
-
11
- describe "Initializing" do
12
- it "should include the module only after initilization" do
13
- refute GraphQL::Tracing::ScoutTracing.included_modules.include?(ScoutApm::Tracer)
14
- assert GraphQL::Tracing::ScoutTracing.new.class.included_modules.include?(ScoutApm::Tracer)
15
- end
16
- end
17
- end
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
- require "spec_helper"
3
-
4
- describe GraphQL::Tracing::SkylightTracing do
5
- module SkylightTest
6
- class Query < GraphQL::Schema::Object
7
- field :int, Integer, null: false
8
-
9
- def int
10
- 1
11
- end
12
- end
13
-
14
- class SchemaWithoutTransactionName < GraphQL::Schema
15
- query(Query)
16
- use(GraphQL::Tracing::SkylightTracing)
17
- if TESTING_INTERPRETER
18
- use GraphQL::Execution::Interpreter
19
- end
20
- end
21
-
22
- class SchemaWithTransactionName < GraphQL::Schema
23
- query(Query)
24
- use(GraphQL::Tracing::SkylightTracing, set_endpoint_name: true)
25
- if TESTING_INTERPRETER
26
- use GraphQL::Execution::Interpreter
27
- end
28
- end
29
-
30
- class SchemaWithScalarTrace < GraphQL::Schema
31
- query(Query)
32
- use(GraphQL::Tracing::SkylightTracing, trace_scalars: true)
33
- end
34
- end
35
-
36
- before do
37
- Skylight.clear_all
38
- end
39
-
40
- it "can leave the transaction name in place" do
41
- SkylightTest::SchemaWithoutTransactionName.execute "query X { int }"
42
- assert_equal [], Skylight::ENDPOINT_NAMES
43
- end
44
-
45
- it "can override the transaction name" do
46
- SkylightTest::SchemaWithTransactionName.execute "query X { int }"
47
- assert_equal ["GraphQL/query.X"], Skylight::ENDPOINT_NAMES
48
- end
49
-
50
- it "can override the transaction name per query" do
51
- # Override with `false`
52
- SkylightTest::SchemaWithTransactionName.execute "{ int }", context: { set_skylight_endpoint_name: false }
53
- assert_equal [], Skylight::ENDPOINT_NAMES
54
- # Override with `true`
55
- SkylightTest::SchemaWithoutTransactionName.execute "{ int }", context: { set_skylight_endpoint_name: true }
56
- assert_equal ["GraphQL/query.<anonymous>"], Skylight::ENDPOINT_NAMES
57
- end
58
-
59
- it "traces scalars when trace_scalars is true" do
60
- SkylightTest::SchemaWithScalarTrace.execute "query X { int }"
61
- assert_includes Skylight::TITLE_NAMES, "graphql.Query.int"
62
- end
63
- end
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
- require "spec_helper"
3
-
4
- describe GraphQL::Tracing do
5
- class DummyTraceable
6
- def initialize(*tracers)
7
- @tracers = tracers
8
- end
9
-
10
- include GraphQL::Tracing::Traceable
11
- end
12
-
13
- describe "#trace" do
14
- it "delivers the metadata to send_trace, with result and key" do
15
- returned_value = nil
16
- traceable = DummyTraceable.new(TestTracing)
17
- traces = TestTracing.with_trace do
18
- returned_value = traceable.trace("something", { some_stuff: true }) do
19
- "do stuff"
20
- end
21
- end
22
-
23
- assert_equal 1, traces.length
24
- trace = traces.first
25
- assert_equal "something", trace[:key]
26
- assert_equal true, trace[:some_stuff]
27
- # Any override of .trace must return the block's return value
28
- assert_equal "do stuff", returned_value
29
- end
30
-
31
- module OtherRandomTracer
32
- CALLS = []
33
-
34
- def self.trace(key, metadata)
35
- CALLS << key.upcase
36
- yield
37
- end
38
- end
39
-
40
- it "calls multiple tracers" do
41
- OtherRandomTracer::CALLS.clear
42
-
43
- traceable = DummyTraceable.new(TestTracing, OtherRandomTracer)
44
- traces = TestTracing.with_trace do
45
- traceable.trace("stuff", { }) { :stuff }
46
- end
47
-
48
- assert_equal ["stuff"], traces.map { |t| t[:key] }
49
- assert_equal ["STUFF"], OtherRandomTracer::CALLS
50
- end
51
- end
52
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
- require "spec_helper"
3
-
4
- describe GraphQL::Types::BigInt do
5
- it "encodes big and small integers as strings" do
6
- big_integer_1 = 99**99
7
- expected_str_1 = "369729637649726772657187905628805440595668764281741102430259972423552570455277523421410650010128232727940978889548326540119429996769494359451621570193644014418071060667659301384999779999159200499899"
8
- assert_equal expected_str_1, GraphQL::Types::BigInt.coerce_result(big_integer_1, nil)
9
- assert_equal big_integer_1, GraphQL::Types::BigInt.coerce_input(expected_str_1, nil)
10
-
11
- big_integer_2 = -(88**88)
12
- expected_str_2 = "-1301592834942972055182648307417315364538725075960067827915311484722452340966317215805106820959190833309704934346517741237438752456673499160125624414995891111204155079786496"
13
- assert_equal expected_str_2, GraphQL::Types::BigInt.coerce_result(big_integer_2, nil)
14
- assert_equal big_integer_2, GraphQL::Types::BigInt.coerce_input(expected_str_2, nil)
15
-
16
- assert_equal "31", GraphQL::Types::BigInt.coerce_result(31, nil)
17
- assert_equal -17, GraphQL::Types::BigInt.coerce_input("-17", nil)
18
- end
19
-
20
- it "returns `nil` for invalid inputs" do
21
- assert_equal nil, GraphQL::Types::BigInt.coerce_input("xyz", nil)
22
- assert_equal nil, GraphQL::Types::BigInt.coerce_input("2.2", nil)
23
- end
24
- end
@@ -1,137 +0,0 @@
1
- # frozen_string_literal: true
2
- require "spec_helper"
3
- require "graphql/types/iso_8601_date_time"
4
- describe GraphQL::Types::ISO8601DateTime do
5
- module DateTimeTest
6
- class DateTimeObject < GraphQL::Schema::Object
7
- field :year, Integer, null: false
8
- field :month, Integer, null: false
9
- field :day, Integer, null: false
10
- field :hour, Integer, null: false
11
- field :minute, Integer, null: false
12
- field :second, Integer, null: false
13
- field :zone, String, null: false
14
- field :iso8601, GraphQL::Types::ISO8601DateTime, null: false, method: :itself
15
- end
16
-
17
- class Query < GraphQL::Schema::Object
18
- field :parse_date, DateTimeObject, null: true do
19
- argument :date, GraphQL::Types::ISO8601DateTime, required: true
20
- end
21
-
22
- def parse_date(date:)
23
- # Date is parsed by the scalar, so it's already a DateTime
24
- date
25
- end
26
- end
27
-
28
-
29
- class Schema < GraphQL::Schema
30
- query(Query)
31
- if TESTING_INTERPRETER
32
- use GraphQL::Execution::Interpreter
33
- end
34
- end
35
- end
36
-
37
-
38
- describe "as an input" do
39
-
40
- def parse_date(date_str)
41
- query_str = <<-GRAPHQL
42
- query($date: ISO8601DateTime!){
43
- parseDate(date: $date) {
44
- year
45
- month
46
- day
47
- hour
48
- minute
49
- second
50
- zone
51
- }
52
- }
53
- GRAPHQL
54
- full_res = DateTimeTest::Schema.execute(query_str, variables: { date: date_str })
55
- full_res["errors"] || full_res["data"]["parseDate"]
56
- end
57
-
58
- it "parses valid dates" do
59
- res = parse_date("2018-06-07T09:31:42-07:00")
60
- expected_res = {
61
- "year" => 2018,
62
- "month" => 6,
63
- "day" => 7,
64
- "hour" => 9,
65
- "minute" => 31,
66
- "second" => 42,
67
- "zone" => "-07:00",
68
- }
69
- assert_equal(expected_res, res)
70
- end
71
-
72
- it "adds an error for invalid dates" do
73
- expected_errors = ["Variable date of type ISO8601DateTime! was provided invalid value"]
74
-
75
- assert_equal expected_errors, parse_date("2018-06-07T99:31:42-07:00").map { |e| e["message"] }
76
- assert_equal expected_errors, parse_date("xyz").map { |e| e["message"] }
77
- assert_equal expected_errors, parse_date(nil).map { |e| e["message"] }
78
- end
79
- end
80
-
81
- describe "as an output" do
82
- it "returns a string" do
83
- query_str = <<-GRAPHQL
84
- query($date: ISO8601DateTime!){
85
- parseDate(date: $date) {
86
- iso8601
87
- }
88
- }
89
- GRAPHQL
90
-
91
- date_str = "2010-02-02T22:30:30-06:00"
92
- full_res = DateTimeTest::Schema.execute(query_str, variables: { date: date_str })
93
- assert_equal date_str, full_res["data"]["parseDate"]["iso8601"]
94
- end
95
-
96
- describe "with time_precision = 3 (i.e. 'with milliseconds')" do
97
- before do
98
- @tp = GraphQL::Types::ISO8601DateTime.time_precision
99
- GraphQL::Types::ISO8601DateTime.time_precision = 3
100
- end
101
-
102
- after do
103
- GraphQL::Types::ISO8601DateTime.time_precision = @tp
104
- end
105
-
106
- it "returns a string" do
107
- query_str = <<-GRAPHQL
108
- query($date: ISO8601DateTime!){
109
- parseDate(date: $date) {
110
- iso8601
111
- }
112
- }
113
- GRAPHQL
114
-
115
- date_str = "2010-02-02T22:30:30.123-06:00"
116
- full_res = DateTimeTest::Schema.execute(query_str, variables: { date: date_str })
117
- assert_equal date_str, full_res["data"]["parseDate"]["iso8601"]
118
- end
119
- end
120
- end
121
-
122
- describe "structure" do
123
- it "is in introspection" do
124
- introspection_res = DateTimeTest::Schema.execute <<-GRAPHQL
125
- {
126
- __type(name: "ISO8601DateTime") {
127
- name
128
- kind
129
- }
130
- }
131
- GRAPHQL
132
-
133
- expected_res = { "name" => "ISO8601DateTime", "kind" => "SCALAR"}
134
- assert_equal expected_res, introspection_res["data"]["__type"]
135
- end
136
- end
137
- end