graphql 1.7.6 → 1.8.0

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.
Files changed (289) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/graphql/function_generator.rb +1 -1
  3. data/lib/generators/graphql/install_generator.rb +14 -8
  4. data/lib/generators/graphql/loader_generator.rb +1 -1
  5. data/lib/generators/graphql/mutation_generator.rb +6 -1
  6. data/lib/generators/graphql/templates/function.erb +2 -2
  7. data/lib/generators/graphql/templates/loader.erb +2 -2
  8. data/lib/generators/graphql/templates/schema.erb +1 -1
  9. data/lib/graphql/argument.rb +25 -19
  10. data/lib/graphql/backtrace/tracer.rb +16 -22
  11. data/lib/graphql/backtrace.rb +1 -1
  12. data/lib/graphql/backwards_compatibility.rb +2 -3
  13. data/lib/graphql/base_type.rb +31 -31
  14. data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +14 -0
  15. data/lib/graphql/compatibility/query_parser_specification.rb +117 -0
  16. data/lib/graphql/define/assign_object_field.rb +5 -12
  17. data/lib/graphql/deprecated_dsl.rb +42 -0
  18. data/lib/graphql/directive.rb +1 -0
  19. data/lib/graphql/enum_type.rb +3 -1
  20. data/lib/graphql/execution/execute.rb +21 -13
  21. data/lib/graphql/execution/instrumentation.rb +82 -0
  22. data/lib/graphql/execution/lazy/lazy_method_map.rb +1 -1
  23. data/lib/graphql/execution/lazy/resolve.rb +1 -3
  24. data/lib/graphql/execution/multiplex.rb +12 -29
  25. data/lib/graphql/execution.rb +1 -0
  26. data/lib/graphql/field.rb +21 -4
  27. data/lib/graphql/function.rb +14 -0
  28. data/lib/graphql/input_object_type.rb +3 -1
  29. data/lib/graphql/interface_type.rb +5 -3
  30. data/lib/graphql/internal_representation/node.rb +26 -14
  31. data/lib/graphql/internal_representation/visit.rb +3 -6
  32. data/lib/graphql/introspection/base_object.rb +16 -0
  33. data/lib/graphql/introspection/directive_location_enum.rb +11 -7
  34. data/lib/graphql/introspection/directive_type.rb +23 -16
  35. data/lib/graphql/introspection/dynamic_fields.rb +11 -0
  36. data/lib/graphql/introspection/entry_points.rb +29 -0
  37. data/lib/graphql/introspection/enum_value_type.rb +16 -11
  38. data/lib/graphql/introspection/field_type.rb +21 -12
  39. data/lib/graphql/introspection/input_value_type.rb +26 -23
  40. data/lib/graphql/introspection/schema_field.rb +7 -2
  41. data/lib/graphql/introspection/schema_type.rb +36 -22
  42. data/lib/graphql/introspection/type_by_name_field.rb +10 -2
  43. data/lib/graphql/introspection/type_kind_enum.rb +10 -6
  44. data/lib/graphql/introspection/type_type.rb +85 -23
  45. data/lib/graphql/introspection/typename_field.rb +1 -0
  46. data/lib/graphql/introspection.rb +3 -10
  47. data/lib/graphql/language/block_string.rb +47 -0
  48. data/lib/graphql/language/document_from_schema_definition.rb +280 -0
  49. data/lib/graphql/language/generation.rb +3 -182
  50. data/lib/graphql/language/lexer.rb +144 -69
  51. data/lib/graphql/language/lexer.rl +15 -4
  52. data/lib/graphql/language/nodes.rb +141 -78
  53. data/lib/graphql/language/parser.rb +677 -630
  54. data/lib/graphql/language/parser.y +18 -12
  55. data/lib/graphql/language/printer.rb +361 -0
  56. data/lib/graphql/language/token.rb +10 -3
  57. data/lib/graphql/language.rb +3 -0
  58. data/lib/graphql/non_null_type.rb +1 -1
  59. data/lib/graphql/object_type.rb +1 -6
  60. data/lib/graphql/query/arguments.rb +63 -32
  61. data/lib/graphql/query/context.rb +32 -2
  62. data/lib/graphql/query/literal_input.rb +4 -1
  63. data/lib/graphql/query/null_context.rb +1 -1
  64. data/lib/graphql/query/result.rb +1 -1
  65. data/lib/graphql/query/variables.rb +21 -3
  66. data/lib/graphql/query.rb +19 -6
  67. data/lib/graphql/railtie.rb +109 -0
  68. data/lib/graphql/relay/connection_resolve.rb +3 -0
  69. data/lib/graphql/relay/connection_type.rb +5 -3
  70. data/lib/graphql/relay/edge_type.rb +2 -1
  71. data/lib/graphql/relay/global_id_resolve.rb +5 -1
  72. data/lib/graphql/relay/mongo_relation_connection.rb +40 -0
  73. data/lib/graphql/relay/mutation/instrumentation.rb +1 -1
  74. data/lib/graphql/relay/mutation/resolve.rb +5 -1
  75. data/lib/graphql/relay/relation_connection.rb +14 -19
  76. data/lib/graphql/relay/type_extensions.rb +30 -0
  77. data/lib/graphql/relay.rb +2 -0
  78. data/lib/graphql/scalar_type.rb +14 -2
  79. data/lib/graphql/schema/argument.rb +92 -0
  80. data/lib/graphql/schema/build_from_definition.rb +64 -18
  81. data/lib/graphql/schema/enum.rb +85 -0
  82. data/lib/graphql/schema/enum_value.rb +74 -0
  83. data/lib/graphql/schema/field.rb +372 -0
  84. data/lib/graphql/schema/finder.rb +153 -0
  85. data/lib/graphql/schema/input_object.rb +87 -0
  86. data/lib/graphql/schema/interface.rb +105 -0
  87. data/lib/graphql/schema/introspection_system.rb +93 -0
  88. data/lib/graphql/schema/late_bound_type.rb +32 -0
  89. data/lib/graphql/schema/list.rb +32 -0
  90. data/lib/graphql/schema/loader.rb +2 -2
  91. data/lib/graphql/schema/member/accepts_definition.rb +152 -0
  92. data/lib/graphql/schema/member/base_dsl_methods.rb +100 -0
  93. data/lib/graphql/schema/member/build_type.rb +137 -0
  94. data/lib/graphql/schema/member/cached_graphql_definition.rb +26 -0
  95. data/lib/graphql/schema/member/graphql_type_names.rb +21 -0
  96. data/lib/graphql/schema/member/has_arguments.rb +50 -0
  97. data/lib/graphql/schema/member/has_fields.rb +130 -0
  98. data/lib/graphql/schema/member/instrumentation.rb +115 -0
  99. data/lib/graphql/schema/member/type_system_helpers.rb +34 -0
  100. data/lib/graphql/schema/member.rb +28 -0
  101. data/lib/graphql/schema/middleware_chain.rb +5 -1
  102. data/lib/graphql/schema/mutation.rb +138 -0
  103. data/lib/graphql/schema/non_null.rb +38 -0
  104. data/lib/graphql/schema/object.rb +81 -0
  105. data/lib/graphql/schema/printer.rb +33 -266
  106. data/lib/graphql/schema/relay_classic_mutation.rb +87 -0
  107. data/lib/graphql/schema/rescue_middleware.rb +8 -7
  108. data/lib/graphql/schema/resolver.rb +122 -0
  109. data/lib/graphql/schema/scalar.rb +35 -0
  110. data/lib/graphql/schema/traversal.rb +102 -22
  111. data/lib/graphql/schema/union.rb +36 -0
  112. data/lib/graphql/schema/validation.rb +3 -2
  113. data/lib/graphql/schema.rb +381 -12
  114. data/lib/graphql/static_validation/definition_dependencies.rb +1 -1
  115. data/lib/graphql/static_validation/literal_validator.rb +16 -4
  116. data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +6 -6
  117. data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +5 -1
  118. data/lib/graphql/static_validation/rules/fields_will_merge.rb +15 -8
  119. data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +11 -1
  120. data/lib/graphql/static_validation/validation_context.rb +1 -1
  121. data/lib/graphql/subscriptions/action_cable_subscriptions.rb +7 -5
  122. data/lib/graphql/subscriptions/instrumentation.rb +5 -1
  123. data/lib/graphql/subscriptions/serialize.rb +2 -0
  124. data/lib/graphql/subscriptions.rb +90 -16
  125. data/lib/graphql/tracing/data_dog_tracing.rb +49 -0
  126. data/lib/graphql/tracing/new_relic_tracing.rb +26 -0
  127. data/lib/graphql/tracing/platform_tracing.rb +20 -7
  128. data/lib/graphql/tracing/scout_tracing.rb +2 -2
  129. data/lib/graphql/tracing.rb +1 -0
  130. data/lib/graphql/unresolved_type_error.rb +3 -2
  131. data/lib/graphql/upgrader/member.rb +894 -0
  132. data/lib/graphql/upgrader/schema.rb +37 -0
  133. data/lib/graphql/version.rb +1 -1
  134. data/lib/graphql.rb +5 -25
  135. data/readme.md +2 -2
  136. data/spec/dummy/app/channels/graphql_channel.rb +23 -2
  137. data/spec/dummy/log/development.log +239 -0
  138. data/spec/dummy/log/test.log +410 -0
  139. data/spec/dummy/test/system/action_cable_subscription_test.rb +4 -0
  140. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/-x/-xYZjAnuuzgR79fcznLTQtSdh6AARxu8FcQ_J6p7L3U.cache +0 -0
  141. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/13/13HiV12xyoQvT-1L39ZzLwMZxjyaGMiENmfw7f-QTIc.cache +0 -0
  142. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/3W/3Wtf5pCWdqq0AB-iB0Y9uUNrTkruRxIEf1XFn_BETU0.cache +1 -0
  143. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5i/5iguGafb4hOn8262Kn8Q37ogNN9MxxQKGKNzHAzUcvI.cache +1 -0
  144. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/8m/8mj2T6yy847Mc2Z7k3Xzh8O91hhVJt3NrPe8ASNDlIA.cache +1 -0
  145. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/DT/DTQyMpr4ABZYQetsdRJ5A7S4jf1r3ie4FGOR7GZBNSs.cache +3 -0
  146. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Dq/DqJ5_yJPrP5iLlOQyTQsjAVI5FE5LCVDkED0f7GgsSo.cache +3 -0
  147. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/F8/F8MUNRzORGFgr329fNM0xLaoWCXdv3BIalT7dsvLfjs.cache +0 -0
  148. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/KB/KB07ZaKNC5uXJ7TjLi-WqnY6g7dq8wWp_8N3HNjBNxg.cache +0 -0
  149. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Rw/RwDuCV-XpnCtjNkvhpJfBuxXMk0b5AD3L9eR6M-wcy0.cache +3 -0
  150. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/UL/ULdjhhb0bRuqmaG7XSZlFYzGYCXTDnqZuJBTWRlzqgw.cache +0 -0
  151. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Up/UpPNgh0yYoUsyMDh5zWqe_U6qJIyTC6-dxMMAs1vvlM.cache +1 -0
  152. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Wg/Wguh-szFGTI1gaL6npYwPekMXflugRei7F_mOyRucXg.cache +0 -0
  153. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/X-/X-khLYMA9mqFRPg3zAi86mREDxpKl4bdKYp3uF6WHos.cache +0 -0
  154. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/bi/BIkdhfxsezxM4q-HZ4oCNTq97WEJTigcq0tpX2cDvbY.cache +0 -0
  155. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ff/FfxmA4CMHQZT7exx0G7NS1Wpcnny0vzp-Jhc2H36bp8.cache +1 -0
  156. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gE/gEiiG4GZNy_djEjK2pHm_NgA-gyhLZhdQvo0Yt96GqE.cache +0 -0
  157. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gn/gnA9ZSqpjccNL2m8pe_jBvY6SinXlCzXDWyop83Od8s.cache +1 -0
  158. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/lO/lOAan3cMwCE_Hli6gsDML88xFNfn0nxPmvrSkW7eEOw.cache +1 -0
  159. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/m1/M1pv8MJEPLXGLvS8QxVh3DSO9cI4mRt5FHFWdrvUj6o.cache +2 -0
  160. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/m7/m77qH7ZqH0_0SmwJbiKGDd-aLau1Dav847DC6ge46zY.cache +1 -0
  161. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/sj/sjRjnjRB37lH2vrgtkdJ8Cz84__IJ978IuKTM7HcztI.cache +0 -0
  162. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/um/um1JrirR4hJhK-1rE-HywlyCi5ibgxHVrReiujZBWJM.cache +1 -0
  163. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/v4/v4fwVytD7ITcE0_GDbslZEYud8a5Okm85fV1o7SDl6g.cache +0 -0
  164. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/v_/v_0PAQt0iipQjFP5zjgkkk9Stnpf4VzvnMv67d1Keuw.cache +1 -0
  165. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/wd/wdT9U4MKxe1PyqNjVuCKMpCl3dxGCIRJIlwUTfh2DQU.cache +1 -0
  166. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/xI/xIaxut_fEIhKBDqljTNwYaADK9kj3gG0ESrfHs-5_og.cache +3 -0
  167. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/y0/y0SJOqIx2fn1SKqOkAihsQow0trRJrSIyAswufVuoA8.cache +0 -0
  168. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/zg/zgpzeaX-KZErHyGJ1aBH3ZusweNXMneVZule88XsIJI.cache +1 -0
  169. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/zy/zYFltDy-8VC-uKq2BVEiJJyYXNFvVzAKuMlR3ZIYZsk.cache +0 -0
  170. data/spec/dummy/tmp/screenshots/failures_test_it_handles_subscriptions.png +0 -0
  171. data/spec/fixtures/upgrader/account.original.rb +19 -0
  172. data/spec/fixtures/upgrader/account.transformed.rb +20 -0
  173. data/spec/fixtures/upgrader/blame_range.original.rb +43 -0
  174. data/spec/fixtures/upgrader/blame_range.transformed.rb +30 -0
  175. data/spec/fixtures/upgrader/date_time.original.rb +24 -0
  176. data/spec/fixtures/upgrader/date_time.transformed.rb +23 -0
  177. data/spec/fixtures/upgrader/delete_project.original.rb +28 -0
  178. data/spec/fixtures/upgrader/delete_project.transformed.rb +27 -0
  179. data/spec/fixtures/upgrader/gist_order_field.original.rb +14 -0
  180. data/spec/fixtures/upgrader/gist_order_field.transformed.rb +13 -0
  181. data/spec/fixtures/upgrader/increment_count.original.rb +59 -0
  182. data/spec/fixtures/upgrader/increment_count.transformed.rb +50 -0
  183. data/spec/fixtures/upgrader/photo.original.rb +10 -0
  184. data/spec/fixtures/upgrader/photo.transformed.rb +12 -0
  185. data/spec/fixtures/upgrader/release_order.original.rb +15 -0
  186. data/spec/fixtures/upgrader/release_order.transformed.rb +14 -0
  187. data/spec/fixtures/upgrader/starrable.original.rb +49 -0
  188. data/spec/fixtures/upgrader/starrable.transformed.rb +46 -0
  189. data/spec/fixtures/upgrader/subscribable.original.rb +55 -0
  190. data/spec/fixtures/upgrader/subscribable.transformed.rb +51 -0
  191. data/spec/fixtures/upgrader/type_x.original.rb +65 -0
  192. data/spec/fixtures/upgrader/type_x.transformed.rb +56 -0
  193. data/spec/generators/graphql/function_generator_spec.rb +26 -0
  194. data/spec/generators/graphql/install_generator_spec.rb +1 -1
  195. data/spec/generators/graphql/loader_generator_spec.rb +24 -0
  196. data/spec/graphql/analysis/max_query_complexity_spec.rb +3 -3
  197. data/spec/graphql/analysis/max_query_depth_spec.rb +3 -3
  198. data/spec/graphql/argument_spec.rb +21 -0
  199. data/spec/graphql/backtrace_spec.rb +10 -0
  200. data/spec/graphql/base_type_spec.rb +42 -0
  201. data/spec/graphql/boolean_type_spec.rb +3 -3
  202. data/spec/graphql/directive_spec.rb +3 -1
  203. data/spec/graphql/enum_type_spec.rb +18 -5
  204. data/spec/graphql/execution/execute_spec.rb +4 -4
  205. data/spec/graphql/execution/instrumentation_spec.rb +165 -0
  206. data/spec/graphql/execution/multiplex_spec.rb +2 -2
  207. data/spec/graphql/execution_error_spec.rb +18 -0
  208. data/spec/graphql/float_type_spec.rb +2 -2
  209. data/spec/graphql/id_type_spec.rb +1 -1
  210. data/spec/graphql/input_object_type_spec.rb +15 -2
  211. data/spec/graphql/int_type_spec.rb +2 -2
  212. data/spec/graphql/interface_type_spec.rb +12 -0
  213. data/spec/graphql/internal_representation/rewrite_spec.rb +2 -2
  214. data/spec/graphql/introspection/schema_type_spec.rb +2 -0
  215. data/spec/graphql/language/block_string_spec.rb +70 -0
  216. data/spec/graphql/language/document_from_schema_definition_spec.rb +770 -0
  217. data/spec/graphql/language/generation_spec.rb +21 -186
  218. data/spec/graphql/language/lexer_spec.rb +21 -1
  219. data/spec/graphql/language/nodes_spec.rb +21 -12
  220. data/spec/graphql/language/parser_spec.rb +1 -1
  221. data/spec/graphql/language/printer_spec.rb +203 -0
  222. data/spec/graphql/object_type_spec.rb +22 -0
  223. data/spec/graphql/query/arguments_spec.rb +25 -15
  224. data/spec/graphql/query/context_spec.rb +18 -0
  225. data/spec/graphql/query/executor_spec.rb +2 -1
  226. data/spec/graphql/query/serial_execution/value_resolution_spec.rb +2 -8
  227. data/spec/graphql/query/variables_spec.rb +42 -1
  228. data/spec/graphql/query_spec.rb +31 -5
  229. data/spec/graphql/rake_task_spec.rb +3 -1
  230. data/spec/graphql/relay/base_connection_spec.rb +1 -1
  231. data/spec/graphql/relay/connection_instrumentation_spec.rb +2 -2
  232. data/spec/graphql/relay/connection_resolve_spec.rb +1 -1
  233. data/spec/graphql/relay/connection_type_spec.rb +1 -1
  234. data/spec/graphql/relay/mongo_relation_connection_spec.rb +474 -0
  235. data/spec/graphql/relay/mutation_spec.rb +9 -7
  236. data/spec/graphql/relay/range_add_spec.rb +5 -1
  237. data/spec/graphql/relay/relation_connection_spec.rb +65 -1
  238. data/spec/graphql/schema/argument_spec.rb +87 -0
  239. data/spec/graphql/schema/build_from_definition_spec.rb +89 -5
  240. data/spec/graphql/schema/enum_spec.rb +74 -0
  241. data/spec/graphql/schema/field_spec.rb +225 -0
  242. data/spec/graphql/schema/finder_spec.rb +135 -0
  243. data/spec/graphql/schema/input_object_spec.rb +111 -0
  244. data/spec/graphql/schema/instrumentation_spec.rb +40 -0
  245. data/spec/graphql/schema/interface_spec.rb +185 -0
  246. data/spec/graphql/schema/introspection_system_spec.rb +39 -0
  247. data/spec/graphql/schema/member/accepts_definition_spec.rb +111 -0
  248. data/spec/graphql/schema/member/build_type_spec.rb +17 -0
  249. data/spec/graphql/schema/member/has_fields_spec.rb +129 -0
  250. data/spec/graphql/schema/member/type_system_helpers_spec.rb +63 -0
  251. data/spec/graphql/schema/mutation_spec.rb +148 -0
  252. data/spec/graphql/schema/object_spec.rb +175 -0
  253. data/spec/graphql/schema/printer_spec.rb +111 -15
  254. data/spec/graphql/schema/relay_classic_mutation_spec.rb +38 -0
  255. data/spec/graphql/schema/rescue_middleware_spec.rb +11 -0
  256. data/spec/graphql/schema/resolver_spec.rb +131 -0
  257. data/spec/graphql/schema/scalar_spec.rb +95 -0
  258. data/spec/graphql/schema/traversal_spec.rb +31 -0
  259. data/spec/graphql/schema/union_spec.rb +65 -0
  260. data/spec/graphql/schema/validation_spec.rb +1 -1
  261. data/spec/graphql/schema/warden_spec.rb +11 -11
  262. data/spec/graphql/schema_spec.rb +55 -12
  263. data/spec/graphql/static_validation/rules/fields_have_appropriate_selections_spec.rb +10 -2
  264. data/spec/graphql/static_validation/rules/fields_will_merge_spec.rb +2 -2
  265. data/spec/graphql/string_type_spec.rb +3 -3
  266. data/spec/graphql/subscriptions_spec.rb +273 -184
  267. data/spec/graphql/tracing/active_support_notifications_tracing_spec.rb +1 -1
  268. data/spec/graphql/tracing/new_relic_tracing_spec.rb +47 -0
  269. data/spec/graphql/tracing/platform_tracing_spec.rb +60 -1
  270. data/spec/graphql/union_type_spec.rb +1 -1
  271. data/spec/graphql/upgrader/member_spec.rb +516 -0
  272. data/spec/graphql/upgrader/schema_spec.rb +82 -0
  273. data/spec/spec_helper.rb +8 -0
  274. data/spec/support/dummy/schema.rb +53 -24
  275. data/spec/support/jazz.rb +544 -0
  276. data/spec/support/lazy_helpers.rb +21 -23
  277. data/spec/support/new_relic.rb +24 -0
  278. data/spec/support/star_trek/data.rb +109 -0
  279. data/spec/support/star_trek/schema.rb +388 -0
  280. data/spec/support/star_wars/data.rb +6 -7
  281. data/spec/support/star_wars/schema.rb +127 -171
  282. metadata +233 -11
  283. data/lib/graphql/introspection/arguments_field.rb +0 -7
  284. data/lib/graphql/introspection/enum_values_field.rb +0 -18
  285. data/lib/graphql/introspection/fields_field.rb +0 -13
  286. data/lib/graphql/introspection/input_fields_field.rb +0 -12
  287. data/lib/graphql/introspection/interfaces_field.rb +0 -11
  288. data/lib/graphql/introspection/of_type_field.rb +0 -6
  289. data/lib/graphql/introspection/possible_types_field.rb +0 -11
@@ -2,200 +2,35 @@
2
2
  require "spec_helper"
3
3
 
4
4
  describe GraphQL::Language::Generation 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
- }
5
+ describe "#to_query_tring" do
6
+ let(:document) {
7
+ GraphQL.parse('type Query { a: String! }')
20
8
  }
21
9
 
22
- fragment moreNestedFields on NestedType @or(something: "ok") {
23
- anotherNestedField
24
- }
25
- |}
26
-
27
- describe ".generate" do
28
- it "generates query string" do
29
- assert_equal query_string.gsub(/^ /, "").strip, document.to_query_string
30
- end
31
-
32
- describe "inputs" do
33
- let(:query_string) {%|
34
- query {
35
- 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")
36
- }
37
- |}
38
-
39
- it "generate" do
40
- assert_equal query_string.gsub(/^ /, "").strip, document.to_query_string
10
+ class CustomPrinter < GraphQL::Language::Printer
11
+ def print_field_definition(print_field_definition)
12
+ "<Field Hidden>"
41
13
  end
42
14
  end
43
15
 
44
- describe "schema" do
45
- describe "schema with convention names for root types" do
46
- let(:query_string) {<<-schema
47
- schema {
48
- query: Query
49
- mutation: Mutation
50
- subscription: Subscription
51
- }
52
- schema
53
- }
54
-
55
- it 'omits schema definition' do
56
- refute document.to_query_string =~ /schema/
57
- end
58
- end
59
-
60
- describe "schema with custom query root name" do
61
- let(:query_string) {<<-schema
62
- schema {
63
- query: MyQuery
64
- mutation: Mutation
65
- subscription: Subscription
66
- }
67
- schema
68
- }
69
-
70
- it 'includes schema definition' do
71
- assert_equal query_string.gsub(/^ /, "").strip, document.to_query_string
72
- end
73
- end
74
-
75
- describe "schema with custom mutation root name" do
76
- let(:query_string) {<<-schema
77
- schema {
78
- query: Query
79
- mutation: MyMutation
80
- subscription: Subscription
81
- }
82
- schema
83
- }
84
-
85
- it 'includes schema definition' do
86
- assert_equal query_string.gsub(/^ /, "").strip, document.to_query_string
87
- end
88
- end
89
-
90
- describe "schema with custom subscription root name" do
91
- let(:query_string) {<<-schema
92
- schema {
93
- query: Query
94
- mutation: Mutation
95
- subscription: MySubscription
96
- }
97
- schema
98
- }
99
-
100
- it 'includes schema definition' do
101
- assert_equal query_string.gsub(/^ /, "").strip, document.to_query_string
102
- end
103
- end
104
-
105
- describe "full featured schema" do
106
- # From: https://github.com/graphql/graphql-js/blob/bc96406ab44453a120da25a0bd6e2b0237119ddf/src/language/__tests__/schema-kitchen-sink.graphql
107
- let(:query_string) {<<-schema
108
- schema {
109
- query: QueryType
110
- mutation: MutationType
111
- }
112
-
113
- # Union description
114
- union AnnotatedUnion @onUnion = A | B
115
-
116
- type Foo implements Bar {
117
- one: Type
118
- two(argument: InputType!): Type
119
- three(argument: InputType, other: String): Int
120
- four(argument: String = "string"): String
121
- five(argument: [String] = ["string", "string"]): String
122
- six(argument: InputType = {key: "value"}): Type
123
- seven(argument: String = null): Type
124
- }
16
+ it "accepts a custom printer" do
17
+ expected = <<-SCHEMA
18
+ type Query {
19
+ a: String!
20
+ }
21
+ SCHEMA
125
22
 
126
- # Scalar description
127
- scalar CustomScalar
128
-
129
- type AnnotatedObject @onObject(arg: "value") {
130
- annotatedField(arg: Type = "default" @onArg): Type @onField
131
- }
132
-
133
- interface Bar {
134
- one: Type
135
- four(argument: String = "string"): String
136
- }
137
-
138
- # Enum description
139
- enum Site {
140
- # Enum value description
141
- DESKTOP
142
- MOBILE
143
- }
144
-
145
- interface AnnotatedInterface @onInterface {
146
- annotatedField(arg: Type @onArg): Type @onField
147
- }
148
-
149
- union Feed = Story | Article | Advert
150
-
151
- # Input description
152
- input InputType {
153
- key: String!
154
- answer: Int = 42
155
- }
156
-
157
- union AnnotatedUnion @onUnion = A | B
158
-
159
- scalar CustomScalar
160
-
161
- # Directive description
162
- directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
163
-
164
- scalar AnnotatedScalar @onScalar
165
-
166
- enum Site {
167
- DESKTOP
168
- MOBILE
169
- }
170
-
171
- enum AnnotatedEnum @onEnum {
172
- ANNOTATED_VALUE @onEnumValue
173
- OTHER_VALUE
174
- }
175
-
176
- input InputType {
177
- key: String!
178
- answer: Int = 42
179
- }
180
-
181
- input AnnotatedInput @onInputObjectType {
182
- annotatedField: Type @onField
183
- }
184
-
185
- directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
186
-
187
- directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
188
- schema
189
- }
23
+ assert_equal expected.chomp, GraphQL::Language::Generation.generate(document)
24
+ end
190
25
 
191
- it "generate" do
192
- assert_equal query_string.gsub(/^ /, "").strip, document.to_query_string
193
- end
26
+ it "accepts a custom printer" do
27
+ expected = <<-SCHEMA
28
+ type Query {
29
+ <Field Hidden>
30
+ }
31
+ SCHEMA
194
32
 
195
- it "doesn't mutate the document" do
196
- assert_equal document.to_query_string, document.to_query_string
197
- end
198
- end
33
+ assert_equal expected.chomp, GraphQL::Language::Generation.generate(document, printer: CustomPrinter.new)
199
34
  end
200
35
  end
201
36
  end
@@ -26,6 +26,15 @@ describe GraphQL::Language::Lexer do
26
26
  assert_equal tokens[0], tokens[1].prev_token
27
27
  end
28
28
 
29
+ describe "block strings" do
30
+ let(:query_string) { %|{ a(b: """\nc\n d\n""")}|}
31
+
32
+ it "tokenizes them" do
33
+ str_token = tokens[5]
34
+ assert_equal "c\n d", str_token.value
35
+ end
36
+ end
37
+
29
38
  it "unescapes escaped characters" do
30
39
  assert_equal "\" \\ / \b \f \n \r \t", subject.tokenize('"\\" \\\\ \\/ \\b \\f \\n \\r \\t"').first.to_s
31
40
  end
@@ -40,7 +49,18 @@ describe GraphQL::Language::Lexer do
40
49
 
41
50
  it "clears the previous_token between runs" do
42
51
  tok_2 = subject.tokenize(query_string)
43
- assert_equal nil, tok_2[0].prev_token
52
+ assert_nil tok_2[0].prev_token
53
+ end
54
+
55
+ it "counts string position properly" do
56
+ tokens = subject.tokenize('{ a(b: "c")}')
57
+ str_token = tokens[5]
58
+ assert_equal :STRING, str_token.name
59
+ assert_equal "c", str_token.value
60
+ assert_equal 8, str_token.col
61
+ assert_equal '(STRING "c" [1:8])', str_token.inspect
62
+ rparen_token = tokens[6]
63
+ assert_equal '(RPAREN ")" [1:10])', rparen_token.inspect
44
64
  end
45
65
  end
46
66
  end
@@ -2,18 +2,6 @@
2
2
  require "spec_helper"
3
3
 
4
4
  describe GraphQL::Language::Nodes::AbstractNode do
5
- describe "child and scalar attributes" do
6
- it "are inherited by node subclasses" do
7
- subclassed_directive = Class.new(GraphQL::Language::Nodes::Directive)
8
-
9
- assert_equal GraphQL::Language::Nodes::Directive.scalar_attributes,
10
- subclassed_directive.scalar_attributes
11
-
12
- assert_equal GraphQL::Language::Nodes::Directive.child_attributes,
13
- subclassed_directive.child_attributes
14
- end
15
- end
16
-
17
5
  describe "#filename" do
18
6
  it "is set after .parse_file" do
19
7
  filename = "spec/support/parser/filename_example.graphql"
@@ -33,4 +21,25 @@ describe GraphQL::Language::Nodes::AbstractNode do
33
21
  assert_nil doc.filename
34
22
  end
35
23
  end
24
+
25
+ describe "#to_query_tring" do
26
+ let(:document) {
27
+ GraphQL.parse('type Query { a: String! }')
28
+ }
29
+
30
+ class CustomPrinter < GraphQL::Language::Printer
31
+ def print_field_definition(print_field_definition)
32
+ "<Field Hidden>"
33
+ end
34
+ end
35
+
36
+ it "accepts a custom printer" do
37
+ expected = <<-SCHEMA
38
+ type Query {
39
+ <Field Hidden>
40
+ }
41
+ SCHEMA
42
+ assert_equal expected.chomp, document.to_query_string(printer: CustomPrinter.new)
43
+ end
44
+ end
36
45
  end
@@ -16,7 +16,7 @@ describe GraphQL::Language::Parser do
16
16
 
17
17
  it "creates an anonymous fragment definition" do
18
18
  assert fragment.is_a?(GraphQL::Language::Nodes::FragmentDefinition)
19
- assert_equal nil, fragment.name
19
+ assert_nil fragment.name
20
20
  assert_equal 1, fragment.selections.length
21
21
  assert_equal "NestedType", fragment.type.name
22
22
  assert_equal 1, fragment.directives.length
@@ -0,0 +1,203 @@
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
@@ -60,6 +60,28 @@ describe GraphQL::ObjectType do
60
60
 
61
61
  assert_raises(ArgumentError) { type.name }
62
62
  end
63
+
64
+ it "doesnt convolute field names that differ with underscore" do
65
+ interface = Module.new do
66
+ include GraphQL::Schema::Interface
67
+ graphql_name 'TestInterface'
68
+ description 'Requires an id'
69
+
70
+ field :id, GraphQL::ID_TYPE, null: false
71
+ end
72
+
73
+ object = Class.new(GraphQL::Schema::Object) do
74
+ graphql_name 'TestObject'
75
+ implements interface
76
+ global_id_field :id
77
+
78
+ # When the validation for `id` is run for `_id`, it will fail because
79
+ # GraphQL::STRING_TYPE cannot be transformed into a GraphQL::ID_TYPE
80
+ field :_id, String, description: 'database id', null: true
81
+ end
82
+
83
+ assert_equal nil, GraphQL::Schema::Validation.validate(object.to_graphql)
84
+ end
63
85
  end
64
86
 
65
87
  it "accepts fields definition" do
@@ -16,14 +16,10 @@ describe GraphQL::Query::Arguments do
16
16
  argument :c, !test_input_1, as: :inputObject
17
17
  end
18
18
 
19
- GraphQL::Query::Arguments.new({
20
- a: 1,
21
- b: 2,
22
- c: GraphQL::Query::Arguments.new({
23
- d: 3,
24
- e: 4,
25
- }, argument_definitions: test_input_1.arguments),
26
- }, argument_definitions: test_input_2.arguments)
19
+ GraphQL::Query::Arguments.construct_arguments_class(test_input_1)
20
+ GraphQL::Query::Arguments.construct_arguments_class(test_input_2)
21
+ arg_values = {a: 1, b: 2, c: { d: 3, e: 4 }}
22
+ test_input_2.arguments_class.new(arg_values, context: nil, defaults_used: Set.new)
27
23
  }
28
24
 
29
25
  it "returns keys as strings, with aliases" do
@@ -73,7 +69,11 @@ describe GraphQL::Query::Arguments do
73
69
  )
74
70
  end
75
71
 
76
- new_arguments = GraphQL::Query::Arguments.new(transformed_args, argument_definitions: types)
72
+ args_class = Class.new(GraphQL::Query::Arguments) do
73
+ self.argument_definitions = types
74
+ end
75
+
76
+ new_arguments = args_class.new(transformed_args, context: nil, defaults_used: Set.new)
77
77
  expected_hash = {
78
78
  "A" => 1,
79
79
  "B" => 2,
@@ -94,9 +94,10 @@ describe GraphQL::Query::Arguments do
94
94
  test_input_type
95
95
  }
96
96
  it "wraps input objects, but not other hashes" do
97
- args = GraphQL::Query::Arguments.new(
97
+ args = input_type.arguments_class.new(
98
98
  {a: 1, b: {a: 2}, c: {a: 3}},
99
- argument_definitions: input_type.arguments
99
+ defaults_used: Set.new,
100
+ context: nil,
100
101
  )
101
102
  assert_kind_of GraphQL::Query::Arguments, args["b"]
102
103
  assert_instance_of Hash, args["c"]
@@ -115,8 +116,8 @@ describe GraphQL::Query::Arguments do
115
116
  end
116
117
 
117
118
  it "returns nil for missing keys" do
118
- assert_equal nil, arguments["z"]
119
- assert_equal nil, arguments[7]
119
+ assert_nil arguments["z"]
120
+ assert_nil arguments[7]
120
121
  end
121
122
  end
122
123
 
@@ -198,6 +199,15 @@ describe GraphQL::Query::Arguments do
198
199
  assert_equal({"a" => 1, "b" => 2}, last_args.to_h)
199
200
  end
200
201
 
202
+ it "indicates when default argument values were applied" do
203
+ schema.execute("{ argTest(a: 1) }")
204
+
205
+ last_args = arg_values.last
206
+
207
+ assert_equal false, last_args.default_used?('a')
208
+ assert_equal true, last_args.default_used?('b')
209
+ end
210
+
201
211
  it "works from variables" do
202
212
  variables = { "arg" => { "a" => 1, "d" => nil } }
203
213
  schema.execute("query ArgTest($arg: TestInput){ argTest(d: $arg) }", variables: variables)
@@ -303,10 +313,10 @@ describe GraphQL::Query::Arguments do
303
313
  end
304
314
 
305
315
  it "generates argument classes that responds to keys as functions" do
306
- assert_equal nil, input_object.arguments_class
316
+ assert_nil input_object.arguments_class
307
317
 
308
318
  GraphQL::Query::Arguments.construct_arguments_class(input_object)
309
- args = input_object.arguments_class.new({foo: 3, bar: -90})
319
+ args = input_object.arguments_class.new({foo: 3, bar: -90}, defaults_used: Set.new, context: nil)
310
320
 
311
321
  assert_equal 3, args.foo
312
322
  assert_equal -90, args.bar
@@ -243,4 +243,22 @@ TABLE
243
243
  assert_equal [expected_err], result["errors"]
244
244
  end
245
245
  end
246
+
247
+ describe "custom context class" do
248
+ it "can be specified" do
249
+ query_str = '{
250
+ inspectContext
251
+ find(id: "Musician/Herbie Hancock") {
252
+ ... on Musician {
253
+ inspectContext
254
+ }
255
+ }
256
+ }'
257
+ res = Jazz::Schema.execute(query_str, context: { magic_key: :ignored, normal_key: "normal_value" })
258
+ expected_values = ["custom_method", "magic_value", "normal_value"]
259
+ expected_values_with_nil = expected_values + [nil]
260
+ assert_equal expected_values, res["data"]["inspectContext"]
261
+ assert_equal expected_values_with_nil, res["data"]["find"]["inspectContext"]
262
+ end
263
+ end
246
264
  end
@@ -188,7 +188,8 @@ describe GraphQL::Query::Executor do
188
188
 
189
189
  describe "if the schema has a rescue handler" do
190
190
  before do
191
- schema.rescue_from(RuntimeError) { "Error was handled!" }
191
+ # HACK: reach to the underlying instance to perform a side-effect
192
+ schema.graphql_definition.rescue_from(RuntimeError) { "Error was handled!" }
192
193
  end
193
194
 
194
195
  after do
@@ -86,10 +86,7 @@ describe GraphQL::Query::SerialExecution::ValueResolution do
86
86
 
87
87
  it "raises an error" do
88
88
  err = assert_raises(GraphQL::UnresolvedTypeError) { result }
89
- expected_message = "The value from \"resolvesToNilInterface\" on \"Query\" could not be resolved to \"SomeInterface\". " \
90
- "(Received: `nil`, Expected: [SomeObject]) " \
91
- "Make sure you have defined a `type_from_object` proc on your schema and that value `1337` " \
92
- "gets resolved to a valid type."
89
+ expected_message = "The value from \"resolvesToNilInterface\" on \"Query\" could not be resolved to \"SomeInterface\". (Received: `nil`, Expected: [SomeObject]) Make sure you have defined a `resolve_type` proc on your schema and that value `1337` gets resolved to a valid type. You may need to add your type to `orphan_types` if it implements an interface but isn't a return type of any other field."
93
90
  assert_equal expected_message, err.message
94
91
  end
95
92
  end
@@ -103,10 +100,7 @@ describe GraphQL::Query::SerialExecution::ValueResolution do
103
100
 
104
101
  it "raises an error" do
105
102
  err = assert_raises(GraphQL::UnresolvedTypeError) { result }
106
- expected_message = "The value from \"resolvesToWrongTypeInterface\" on \"Query\" could not be resolved to \"SomeInterface\". " \
107
- "(Received: `OtherObject`, Expected: [SomeObject]) " \
108
- "Make sure you have defined a `type_from_object` proc on your schema and that value `:something` " \
109
- "gets resolved to a valid type."
103
+ expected_message = "The value from \"resolvesToWrongTypeInterface\" on \"Query\" could not be resolved to \"SomeInterface\". (Received: `OtherObject`, Expected: [SomeObject]) Make sure you have defined a `resolve_type` proc on your schema and that value `:something` gets resolved to a valid type. You may need to add your type to `orphan_types` if it implements an interface but isn't a return type of any other field."
110
104
  assert_equal expected_message, err.message
111
105
  end
112
106
  end