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
@@ -82,8 +82,7 @@ rule
82
82
  | EQUALS literal_value { return val[1] }
83
83
 
84
84
  selection_set:
85
- LCURLY RCURLY { return [] }
86
- | LCURLY selection_list RCURLY { return val[1] }
85
+ LCURLY selection_list RCURLY { return val[1] }
87
86
 
88
87
  selection_set_opt:
89
88
  /* none */ { return [] }
@@ -153,12 +152,8 @@ rule
153
152
  | operation_type
154
153
  | schema_keyword
155
154
 
156
- name_list:
157
- name { return [make_node(:TypeName, name: val[0])] }
158
- | name_list name { val[0] << make_node(:TypeName, name: val[1]) }
159
-
160
155
  enum_value_definition:
161
- enum_name directives_list_opt { return make_node(:EnumValueDefinition, name: val[0], directives: val[1], description: get_description(val[0])) }
156
+ enum_name directives_list_opt { return make_node(:EnumValueDefinition, name: val[0], directives: val[1], description: get_description(val[0]), position_source: val[0]) }
162
157
 
163
158
  enum_value_definitions:
164
159
  enum_value_definition { return [val[0]] }
@@ -281,7 +276,7 @@ rule
281
276
  | directive_definition
282
277
 
283
278
  schema_definition:
284
- SCHEMA LCURLY operation_type_definition_list RCURLY { return make_node(:SchemaDefinition, position_source: val[0], **val[2]) }
279
+ SCHEMA directives_list_opt LCURLY operation_type_definition_list RCURLY { return make_node(:SchemaDefinition, position_source: val[0], directives: val[1], **val[3]) }
285
280
 
286
281
  operation_type_definition_list:
287
282
  operation_type_definition
@@ -307,11 +302,21 @@ rule
307
302
 
308
303
  implements_opt:
309
304
  /* none */ { return [] }
310
- | IMPLEMENTS name_list { return val[1] }
305
+ | IMPLEMENTS AMP interfaces_list { return val[2] }
306
+ | IMPLEMENTS interfaces_list { return val[1] }
307
+ | IMPLEMENTS legacy_interfaces_list { return val[1] }
308
+
309
+ interfaces_list:
310
+ name { return [make_node(:TypeName, name: val[0], position_source: val[0])] }
311
+ | interfaces_list AMP name { val[0] << make_node(:TypeName, name: val[2], position_source: val[2]) }
312
+
313
+ legacy_interfaces_list:
314
+ name { return [make_node(:TypeName, name: val[0], position_source: val[0])] }
315
+ | legacy_interfaces_list name { val[0] << make_node(:TypeName, name: val[1], position_source: val[1]) }
311
316
 
312
317
  input_value_definition:
313
318
  name COLON type default_value_opt directives_list_opt {
314
- return make_node(:InputValueDefinition, name: val[0], type: val[2], default_value: val[3], directives: val[4], description: get_description(val[0]))
319
+ return make_node(:InputValueDefinition, name: val[0], type: val[2], default_value: val[3], directives: val[4], description: get_description(val[0]), position_source: val[0])
315
320
  }
316
321
 
317
322
  input_value_definition_list:
@@ -324,11 +329,12 @@ rule
324
329
 
325
330
  field_definition:
326
331
  name arguments_definitions_opt COLON type directives_list_opt {
327
- return make_node(:FieldDefinition, name: val[0], arguments: val[1], type: val[3], directives: val[4], description: get_description(val[0]))
332
+ return make_node(:FieldDefinition, name: val[0], arguments: val[1], type: val[3], directives: val[4], description: get_description(val[0]), position_source: val[0])
328
333
  }
329
334
 
330
335
  field_definition_list:
331
- field_definition { return [val[0]] }
336
+ /* none */ { return [] }
337
+ | field_definition { return [val[0]] }
332
338
  | field_definition_list field_definition { val[0] << val[1] }
333
339
 
334
340
  interface_type_definition:
@@ -0,0 +1,361 @@
1
+ # frozen_string_literal: true
2
+ module GraphQL
3
+ module Language
4
+ class Printer
5
+ # Turn an arbitrary AST node back into a string.
6
+ #
7
+ # @example Turning a document into a query string
8
+ # document = GraphQL.parse(query_string)
9
+ # GraphQL::Language::Printer.new.print(document)
10
+ # # => "{ ... }"
11
+ #
12
+ #
13
+ # @example Building a custom printer
14
+ #
15
+ # class MyPrinter < GraphQL::Language::Printer
16
+ # def print_argument(arg)
17
+ # "#{arg.name}: <HIDDEN>"
18
+ # end
19
+ # end
20
+ #
21
+ # MyPrinter.new.print(document)
22
+ # # => "mutation { pay(creditCard: <HIDDEN>) { success } }"
23
+ #
24
+ #
25
+ # @param indent [String] Whitespace to add to the printed node
26
+ # @return [String] Valid GraphQL for `node`
27
+ def print(node, indent: "")
28
+ print_node(node, indent: indent)
29
+ end
30
+
31
+ protected
32
+
33
+ def print_document(document)
34
+ document.definitions.map { |d| print_node(d) }.join("\n\n")
35
+ end
36
+
37
+ def print_argument(argument)
38
+ "#{argument.name}: #{print_node(argument.value)}".dup
39
+ end
40
+
41
+ def print_directive(directive)
42
+ out = "@#{directive.name}".dup
43
+
44
+ if directive.arguments.any?
45
+ out << "(#{directive.arguments.map { |a| print_argument(a) }.join(", ")})"
46
+ end
47
+
48
+ out
49
+ end
50
+
51
+ def print_enum(enum)
52
+ "#{enum.name}".dup
53
+ end
54
+
55
+ def print_null_value
56
+ "null".dup
57
+ end
58
+
59
+ def print_field(field, indent: "")
60
+ out = "#{indent}".dup
61
+ out << "#{field.alias}: " if field.alias
62
+ out << "#{field.name}"
63
+ out << "(#{field.arguments.map { |a| print_argument(a) }.join(", ")})" if field.arguments.any?
64
+ out << print_directives(field.directives)
65
+ out << print_selections(field.selections, indent: indent)
66
+ out
67
+ end
68
+
69
+ def print_fragment_definition(fragment_def, indent: "")
70
+ out = "#{indent}fragment #{fragment_def.name}".dup
71
+ if fragment_def.type
72
+ out << " on #{print_node(fragment_def.type)}"
73
+ end
74
+ out << print_directives(fragment_def.directives)
75
+ out << print_selections(fragment_def.selections, indent: indent)
76
+ out
77
+ end
78
+
79
+ def print_fragment_spread(fragment_spread, indent: "")
80
+ out = "#{indent}...#{fragment_spread.name}".dup
81
+ out << print_directives(fragment_spread.directives)
82
+ out
83
+ end
84
+
85
+ def print_inline_fragment(inline_fragment, indent: "")
86
+ out = "#{indent}...".dup
87
+ if inline_fragment.type
88
+ out << " on #{print_node(inline_fragment.type)}"
89
+ end
90
+ out << print_directives(inline_fragment.directives)
91
+ out << print_selections(inline_fragment.selections, indent: indent)
92
+ out
93
+ end
94
+
95
+ def print_input_object(input_object)
96
+ "{#{input_object.arguments.map { |a| "#{a.name}: #{print(a.value)}" }.join(", ")}}"
97
+ end
98
+
99
+ def print_list_type(list_type)
100
+ "[#{print_node(list_type.of_type)}]".dup
101
+ end
102
+
103
+ def print_non_null_type(non_null_type)
104
+ "#{print_node(non_null_type.of_type)}!".dup
105
+ end
106
+
107
+ def print_operation_definition(operation_definition, indent: "")
108
+ out = "#{indent}#{operation_definition.operation_type}".dup
109
+ out << " #{operation_definition.name}" if operation_definition.name
110
+
111
+ if operation_definition.variables.any?
112
+ out << "(#{operation_definition.variables.map { |v| print_variable_definition(v) }.join(", ")})"
113
+ end
114
+
115
+ out << print_directives(operation_definition.directives)
116
+ out << print_selections(operation_definition.selections, indent: indent)
117
+ out
118
+ end
119
+
120
+ def print_type_name(type_name)
121
+ "#{type_name.name}".dup
122
+ end
123
+
124
+ def print_variable_definition(variable_definition)
125
+ out = "$#{variable_definition.name}: #{print_node(variable_definition.type)}".dup
126
+ out << " = #{print_node(variable_definition.default_value)}" unless variable_definition.default_value.nil?
127
+ out
128
+ end
129
+
130
+ def print_variable_identifier(variable_identifier)
131
+ "$#{variable_identifier.name}".dup
132
+ end
133
+
134
+ def print_schema_definition(schema)
135
+ if (schema.query.nil? || schema.query == 'Query') &&
136
+ (schema.mutation.nil? || schema.mutation == 'Mutation') &&
137
+ (schema.subscription.nil? || schema.subscription == 'Subscription') &&
138
+ (schema.directives.none?)
139
+ return
140
+ end
141
+
142
+ out = "schema".dup
143
+ if schema.directives.any?
144
+ schema.directives.each do |dir|
145
+ out << "\n "
146
+ out << print_node(dir)
147
+ end
148
+ out << "\n{"
149
+ else
150
+ out << " {\n"
151
+ end
152
+ out << " query: #{schema.query}\n" if schema.query
153
+ out << " mutation: #{schema.mutation}\n" if schema.mutation
154
+ out << " subscription: #{schema.subscription}\n" if schema.subscription
155
+ out << "}"
156
+ end
157
+
158
+ def print_scalar_type_definition(scalar_type)
159
+ out = print_description(scalar_type)
160
+ out << "scalar #{scalar_type.name}"
161
+ out << print_directives(scalar_type.directives)
162
+ end
163
+
164
+ def print_object_type_definition(object_type)
165
+ out = print_description(object_type)
166
+ out << "type #{object_type.name}"
167
+ out << " implements " << object_type.interfaces.map(&:name).join(" & ") unless object_type.interfaces.empty?
168
+ out << print_directives(object_type.directives)
169
+ out << print_field_definitions(object_type.fields)
170
+ end
171
+
172
+ def print_input_value_definition(input_value)
173
+ out = "#{input_value.name}: #{print_node(input_value.type)}".dup
174
+ out << " = #{print_node(input_value.default_value)}" unless input_value.default_value.nil?
175
+ out << print_directives(input_value.directives)
176
+ end
177
+
178
+ def print_arguments(arguments, indent: "")
179
+ if arguments.all?{ |arg| !arg.description }
180
+ return "(#{arguments.map{ |arg| print_input_value_definition(arg) }.join(", ")})"
181
+ end
182
+
183
+ out = "(\n".dup
184
+ out << arguments.map.with_index{ |arg, i|
185
+ "#{print_description(arg, indent: " " + indent, first_in_block: i == 0)} #{indent}"\
186
+ "#{print_input_value_definition(arg)}"
187
+ }.join("\n")
188
+ out << "\n#{indent})"
189
+ end
190
+
191
+ def print_field_definition(field)
192
+ out = field.name.dup
193
+ unless field.arguments.empty?
194
+ out << print_arguments(field.arguments, indent: " ")
195
+ end
196
+ out << ": #{print_node(field.type)}"
197
+ out << print_directives(field.directives)
198
+ end
199
+
200
+ def print_interface_type_definition(interface_type)
201
+ out = print_description(interface_type)
202
+ out << "interface #{interface_type.name}"
203
+ out << print_directives(interface_type.directives)
204
+ out << print_field_definitions(interface_type.fields)
205
+ end
206
+
207
+ def print_union_type_definition(union_type)
208
+ out = print_description(union_type)
209
+ out << "union #{union_type.name}"
210
+ out << print_directives(union_type.directives)
211
+ out << " = " + union_type.types.map(&:name).join(" | ")
212
+ end
213
+
214
+ def print_enum_type_definition(enum_type)
215
+ out = print_description(enum_type)
216
+ out << "enum #{enum_type.name}#{print_directives(enum_type.directives)} {\n"
217
+ enum_type.values.each.with_index do |value, i|
218
+ out << print_description(value, indent: ' ', first_in_block: i == 0)
219
+ out << print_enum_value_definition(value)
220
+ end
221
+ out << "}"
222
+ end
223
+
224
+ def print_enum_value_definition(enum_value)
225
+ out = " #{enum_value.name}".dup
226
+ out << print_directives(enum_value.directives)
227
+ out << "\n"
228
+ end
229
+
230
+ def print_input_object_type_definition(input_object_type)
231
+ out = print_description(input_object_type)
232
+ out << "input #{input_object_type.name}"
233
+ out << print_directives(input_object_type.directives)
234
+ out << " {\n"
235
+ input_object_type.fields.each.with_index do |field, i|
236
+ out << print_description(field, indent: ' ', first_in_block: i == 0)
237
+ out << " #{print_input_value_definition(field)}\n"
238
+ end
239
+ out << "}"
240
+ end
241
+
242
+ def print_directive_definition(directive)
243
+ out = print_description(directive)
244
+ out << "directive @#{directive.name}"
245
+
246
+ if directive.arguments.any?
247
+ out << print_arguments(directive.arguments)
248
+ end
249
+
250
+ out << " on #{directive.locations.join(' | ')}"
251
+ end
252
+
253
+ def print_description(node, indent: "", first_in_block: true)
254
+ return ''.dup unless node.description
255
+
256
+ description = indent != '' && !first_in_block ? "\n".dup : "".dup
257
+ description << GraphQL::Language::Comments.commentize(node.description, indent: indent)
258
+ end
259
+
260
+ def print_field_definitions(fields)
261
+ out = " {\n".dup
262
+ fields.each.with_index do |field, i|
263
+ out << print_description(field, indent: ' ', first_in_block: i == 0)
264
+ out << " #{print_field_definition(field)}\n"
265
+ end
266
+ out << "}"
267
+ end
268
+
269
+ def print_directives(directives)
270
+ if directives.any?
271
+ directives.map { |d| " #{print_directive(d)}" }.join
272
+ else
273
+ ""
274
+ end
275
+ end
276
+
277
+ def print_selections(selections, indent: "")
278
+ if selections.any?
279
+ out = " {\n".dup
280
+ selections.each do |selection|
281
+ out << print_node(selection, indent: indent + " ") << "\n"
282
+ end
283
+ out << "#{indent}}"
284
+ else
285
+ ""
286
+ end
287
+ end
288
+
289
+ def print_node(node, indent: "")
290
+ case node
291
+ when Nodes::Document
292
+ print_document(node)
293
+ when Nodes::Argument
294
+ print_argument(node)
295
+ when Nodes::Directive
296
+ print_directive(node)
297
+ when Nodes::Enum
298
+ print_enum(node)
299
+ when Nodes::NullValue
300
+ print_null_value
301
+ when Nodes::Field
302
+ print_field(node, indent: indent)
303
+ when Nodes::FragmentDefinition
304
+ print_fragment_definition(node, indent: indent)
305
+ when Nodes::FragmentSpread
306
+ print_fragment_spread(node, indent: indent)
307
+ when Nodes::InlineFragment
308
+ print_inline_fragment(node, indent: indent)
309
+ when Nodes::InputObject
310
+ print_input_object(node)
311
+ when Nodes::ListType
312
+ print_list_type(node)
313
+ when Nodes::NonNullType
314
+ print_non_null_type(node)
315
+ when Nodes::OperationDefinition
316
+ print_operation_definition(node, indent: indent)
317
+ when Nodes::TypeName
318
+ print_type_name(node)
319
+ when Nodes::VariableDefinition
320
+ print_variable_definition(node)
321
+ when Nodes::VariableIdentifier
322
+ print_variable_identifier(node)
323
+ when Nodes::SchemaDefinition
324
+ print_schema_definition(node)
325
+ when Nodes::ScalarTypeDefinition
326
+ print_scalar_type_definition(node)
327
+ when Nodes::ObjectTypeDefinition
328
+ print_object_type_definition(node)
329
+ when Nodes::InputValueDefinition
330
+ print_input_value_definition(node)
331
+ when Nodes::FieldDefinition
332
+ print_field_definition(node)
333
+ when Nodes::InterfaceTypeDefinition
334
+ print_interface_type_definition(node)
335
+ when Nodes::UnionTypeDefinition
336
+ print_union_type_definition(node)
337
+ when Nodes::EnumTypeDefinition
338
+ print_enum_type_definition(node)
339
+ when Nodes::EnumValueDefinition
340
+ print_enum_value_definition(node)
341
+ when Nodes::InputObjectTypeDefinition
342
+ print_input_object_type_definition(node)
343
+ when Nodes::DirectiveDefinition
344
+ print_directive_definition(node)
345
+ when FalseClass, Float, Integer, NilClass, String, TrueClass, Symbol
346
+ GraphQL::Language.serialize(node)
347
+ when Array
348
+ "[#{node.map { |v| print_node(v) }.join(", ")}]".dup
349
+ when Hash
350
+ "{#{node.map { |k, v| "#{k}: #{print_node(v)}" }.join(", ")}}".dup
351
+ else
352
+ GraphQL::Language.serialize(node.to_s)
353
+ end
354
+ end
355
+
356
+ private
357
+
358
+ attr_reader :node
359
+ end
360
+ end
361
+ end
@@ -5,23 +5,30 @@ module GraphQL
5
5
  # Contains type, value and position data.
6
6
  class Token
7
7
  # @return [Symbol] The kind of token this is
8
- attr_reader :name, :prev_token, :line
8
+ attr_reader :name
9
+ # @return [String] The text of this token
10
+ attr_reader :value
11
+ attr_reader :prev_token, :line, :col
9
12
 
10
13
  def initialize(value:, name:, line:, col:, prev_token:)
11
14
  @name = name
12
- @value = value
15
+ @value = value.freeze
13
16
  @line = line
14
17
  @col = col
15
18
  @prev_token = prev_token
16
19
  end
17
20
 
18
- def to_s; @value; end
21
+ alias to_s value
19
22
  def to_i; @value.to_i; end
20
23
  def to_f; @value.to_f; end
21
24
 
22
25
  def line_and_column
23
26
  [@line, @col]
24
27
  end
28
+
29
+ def inspect
30
+ "(#{@name} #{@value.inspect} [#{@line}:#{@col}])"
31
+ end
25
32
  end
26
33
  end
27
34
  end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
+ require "graphql/language/block_string"
3
+ require "graphql/language/printer"
2
4
  require "graphql/language/definition_slice"
5
+ require "graphql/language/document_from_schema_definition"
3
6
  require "graphql/language/generation"
4
7
  require "graphql/language/lexer"
5
8
  require "graphql/language/nodes"
@@ -33,7 +33,7 @@ module GraphQL
33
33
  #
34
34
  class NonNullType < GraphQL::BaseType
35
35
  include GraphQL::BaseType::ModifiesAnotherType
36
- extend GraphQL::Delegate
36
+ extend Forwardable
37
37
 
38
38
  attr_reader :of_type
39
39
  def initialize(of_type:)
@@ -32,7 +32,7 @@ module GraphQL
32
32
  # @return [Hash<String => GraphQL::Field>] Map String fieldnames to their {GraphQL::Field} implementations
33
33
 
34
34
  # @!attribute mutation
35
- # @return [GraphQL::Relay::Mutation, nil] The mutation this field was derived from, if it was derived from a mutation
35
+ # @return [GraphQL::Relay::Mutation, nil] The mutation this object type was derived from, if it is an auto-generated payload type.
36
36
 
37
37
  def initialize
38
38
  super
@@ -102,11 +102,6 @@ module GraphQL
102
102
  dirty_ifaces.concat(interfaces)
103
103
  end
104
104
 
105
- def name=(name)
106
- GraphQL::NameValidator.validate!(name)
107
- @name = name
108
- end
109
-
110
105
  protected
111
106
 
112
107
  attr_reader :dirty_interfaces, :dirty_inherited_interfaces
@@ -5,44 +5,44 @@ module GraphQL
5
5
  #
6
6
  # {Arguments} recursively wraps the input in {Arguments} instances.
7
7
  class Arguments
8
- extend GraphQL::Delegate
8
+ extend Forwardable
9
9
 
10
10
  def self.construct_arguments_class(argument_owner)
11
11
  argument_definitions = argument_owner.arguments
12
12
  argument_owner.arguments_class = Class.new(self) do
13
13
  self.argument_definitions = argument_definitions
14
14
 
15
- def initialize(values)
16
- super(values, argument_definitions: self.class.argument_definitions)
17
- end
18
-
19
15
  argument_definitions.each do |_arg_name, arg_definition|
20
16
  expose_as = arg_definition.expose_as.to_s
21
-
22
- # Don't define a helper method if it would override something.
23
- if instance_methods.include?(expose_as)
24
- warn(
25
- "Unable to define a helper for argument with name '#{expose_as}' "\
26
- "as this is a reserved name. If you're using an argument such as "\
27
- "`argument #{expose_as}`, consider renaming this argument.`"
28
- )
29
- next
30
- end
31
-
32
- define_method(expose_as) do
33
- self[expose_as]
17
+ expose_as_underscored = GraphQL::Schema::Member::BuildType.underscore(expose_as)
18
+ method_names = [expose_as, expose_as_underscored].uniq
19
+ method_names.each do |method_name|
20
+ # Don't define a helper method if it would override something.
21
+ if instance_methods.include?(method_name)
22
+ warn(
23
+ "Unable to define a helper for argument with name '#{method_name}' "\
24
+ "as this is a reserved name. If you're using an argument such as "\
25
+ "`argument #{method_name}`, consider renaming this argument.`"
26
+ )
27
+ else
28
+ define_method(method_name) do
29
+ # Always use `expose_as` here, since #[] doesn't accept underscored names
30
+ self[expose_as]
31
+ end
32
+ end
34
33
  end
35
34
  end
36
35
  end
37
36
  end
38
37
 
39
- def initialize(values, argument_definitions:)
38
+ def initialize(values, context:, defaults_used:)
40
39
  @argument_values = values.inject({}) do |memo, (inner_key, inner_value)|
41
- arg_defn = argument_definitions[inner_key.to_s]
42
-
43
- arg_value = wrap_value(inner_value, arg_defn.type)
40
+ arg_name = inner_key.to_s
41
+ arg_defn = self.class.argument_definitions[arg_name]
42
+ arg_default_used = defaults_used.include?(arg_name)
43
+ arg_value = wrap_value(inner_value, arg_defn.type, context)
44
44
  string_key = arg_defn.expose_as
45
- memo[string_key] = ArgumentValue.new(string_key, arg_value, arg_defn)
45
+ memo[string_key] = ArgumentValue.new(string_key, arg_value, arg_defn, arg_default_used)
46
46
  memo
47
47
  end
48
48
  end
@@ -61,6 +61,13 @@ module GraphQL
61
61
  @argument_values.key?(key_s)
62
62
  end
63
63
 
64
+ # @param key [String, Symbol] name of value to access
65
+ # @return [Boolean] true if the argument default was passed as the argument value to the resolver
66
+ def default_used?(key)
67
+ key_s = key.is_a?(String) ? key : key.to_s
68
+ @argument_values.fetch(key_s, NULL_ARGUMENT_VALUE).default_used?
69
+ end
70
+
64
71
  # Get the hash of all values, with stringified keys
65
72
  # @return [Hash] the stringified hash
66
73
  def to_h
@@ -74,7 +81,7 @@ module GraphQL
74
81
  end
75
82
  end
76
83
 
77
- def_delegators :to_h, :keys, :values, :each
84
+ def_delegators :to_h, :keys, :values, :each, :any?
78
85
 
79
86
  # Access each key, value and type for the arguments in this set.
80
87
  # @yield [argument_value] The {ArgumentValue} for each argument
@@ -85,37 +92,61 @@ module GraphQL
85
92
  end
86
93
  end
87
94
 
88
- NO_ARGS = self.new({}, argument_definitions: [])
89
-
90
95
  class << self
91
96
  attr_accessor :argument_definitions
92
97
  end
93
98
 
99
+ NoArguments = Class.new(self) do
100
+ self.argument_definitions = []
101
+ end
102
+
103
+ NO_ARGS = NoArguments.new({}, context: nil, defaults_used: Set.new)
104
+
105
+ # Convert this instance into valid Ruby keyword arguments
106
+ # @return [{Symbol=>Object}]
107
+ def to_kwargs
108
+ ruby_kwargs = {}
109
+
110
+ keys.each do |key|
111
+ ruby_kwargs[Schema::Member::BuildType.underscore(key).to_sym] = self[key]
112
+ end
113
+
114
+ ruby_kwargs
115
+ end
116
+
94
117
  private
95
118
 
96
119
  class ArgumentValue
97
120
  attr_reader :key, :value, :definition
98
- def initialize(key, value, definition)
121
+ attr_writer :default_used
122
+
123
+ def initialize(key, value, definition, default_used)
99
124
  @key = key
100
125
  @value = value
101
126
  @definition = definition
127
+ @default_used = default_used
128
+ end
129
+
130
+ # @return [Boolean] true if the argument default was passed as the argument value to the resolver
131
+ def default_used?
132
+ @default_used
102
133
  end
103
134
  end
104
135
 
105
- NULL_ARGUMENT_VALUE = ArgumentValue.new(nil, nil, nil)
136
+ NULL_ARGUMENT_VALUE = ArgumentValue.new(nil, nil, nil, nil)
106
137
 
107
- def wrap_value(value, arg_defn_type)
138
+ def wrap_value(value, arg_defn_type, context)
108
139
  if value.nil?
109
140
  nil
110
141
  else
111
142
  case arg_defn_type
112
143
  when GraphQL::ListType
113
- value.map { |item| wrap_value(item, arg_defn_type.of_type) }
144
+ value.map { |item| wrap_value(item, arg_defn_type.of_type, context) }
114
145
  when GraphQL::NonNullType
115
- wrap_value(value, arg_defn_type.of_type)
146
+ wrap_value(value, arg_defn_type.of_type, context)
116
147
  when GraphQL::InputObjectType
117
148
  if value.is_a?(Hash)
118
- arg_defn_type.arguments_class.new(value)
149
+ arg_defn_type.arguments_class.new(value, context: context, defaults_used: Set.new)
119
150
  else
120
151
  value
121
152
  end