graphql 1.13.5 → 1.13.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/graphql/core.rb +0 -7
  3. data/lib/generators/graphql/enum_generator.rb +4 -10
  4. data/lib/generators/graphql/field_extractor.rb +31 -0
  5. data/lib/generators/graphql/input_generator.rb +50 -0
  6. data/lib/generators/graphql/install/mutation_root_generator.rb +34 -0
  7. data/lib/generators/graphql/{templates → install/templates}/base_mutation.erb +0 -0
  8. data/lib/generators/graphql/{templates → install/templates}/mutation_type.erb +0 -0
  9. data/lib/generators/graphql/install_generator.rb +1 -1
  10. data/lib/generators/graphql/interface_generator.rb +7 -7
  11. data/lib/generators/graphql/mutation_create_generator.rb +22 -0
  12. data/lib/generators/graphql/mutation_delete_generator.rb +22 -0
  13. data/lib/generators/graphql/mutation_generator.rb +5 -30
  14. data/lib/generators/graphql/mutation_update_generator.rb +22 -0
  15. data/lib/generators/graphql/object_generator.rb +8 -37
  16. data/lib/generators/graphql/orm_mutations_base.rb +40 -0
  17. data/lib/generators/graphql/scalar_generator.rb +4 -2
  18. data/lib/generators/graphql/templates/enum.erb +5 -1
  19. data/lib/generators/graphql/templates/input.erb +9 -0
  20. data/lib/generators/graphql/templates/interface.erb +4 -2
  21. data/lib/generators/graphql/templates/mutation.erb +1 -1
  22. data/lib/generators/graphql/templates/mutation_create.erb +20 -0
  23. data/lib/generators/graphql/templates/mutation_delete.erb +20 -0
  24. data/lib/generators/graphql/templates/mutation_update.erb +21 -0
  25. data/lib/generators/graphql/templates/object.erb +4 -2
  26. data/lib/generators/graphql/templates/scalar.erb +3 -1
  27. data/lib/generators/graphql/templates/union.erb +4 -2
  28. data/lib/generators/graphql/type_generator.rb +46 -9
  29. data/lib/generators/graphql/union_generator.rb +5 -5
  30. data/lib/graphql/analysis/ast/visitor.rb +2 -1
  31. data/lib/graphql/dataloader/source.rb +2 -2
  32. data/lib/graphql/date_encoding_error.rb +16 -0
  33. data/lib/graphql/execution/interpreter/runtime.rb +29 -14
  34. data/lib/graphql/introspection/directive_location_enum.rb +2 -2
  35. data/lib/graphql/introspection/directive_type.rb +2 -0
  36. data/lib/graphql/introspection/schema_type.rb +5 -0
  37. data/lib/graphql/introspection/type_type.rb +9 -3
  38. data/lib/graphql/introspection.rb +4 -1
  39. data/lib/graphql/pagination/relation_connection.rb +4 -4
  40. data/lib/graphql/rubocop/graphql/default_required_true.rb +4 -4
  41. data/lib/graphql/schema/argument.rb +18 -1
  42. data/lib/graphql/schema/directive.rb +11 -0
  43. data/lib/graphql/schema/field.rb +21 -12
  44. data/lib/graphql/schema/input_object.rb +1 -1
  45. data/lib/graphql/schema/loader.rb +3 -0
  46. data/lib/graphql/schema/scalar.rb +12 -0
  47. data/lib/graphql/schema.rb +12 -5
  48. data/lib/graphql/types/iso_8601_date.rb +13 -5
  49. data/lib/graphql/types/iso_8601_date_time.rb +8 -1
  50. data/lib/graphql/types/relay/connection_behaviors.rb +2 -1
  51. data/lib/graphql/version.rb +1 -1
  52. data/lib/graphql.rb +12 -0
  53. metadata +20 -8
@@ -21,13 +21,21 @@ module GraphQL
21
21
  Date.parse(value.to_s).iso8601
22
22
  end
23
23
 
24
- # @param str_value [String]
24
+ # @param str_value [String, Date, DateTime, Time]
25
25
  # @return [Date]
26
- def self.coerce_input(str_value, _ctx)
27
- Date.iso8601(str_value)
26
+ def self.coerce_input(value, ctx)
27
+ if value.is_a?(::Date)
28
+ value
29
+ elsif value.is_a?(::DateTime)
30
+ value.to_date
31
+ elsif value.is_a?(::Time)
32
+ value.to_date
33
+ else
34
+ Date.iso8601(value)
35
+ end
28
36
  rescue ArgumentError, TypeError
29
- # Invalid input
30
- nil
37
+ err = GraphQL::DateEncodingError.new(value)
38
+ ctx.schema.type_error(err, ctx)
31
39
  end
32
40
  end
33
41
  end
@@ -54,7 +54,14 @@ module GraphQL
54
54
  Time.iso8601(str_value)
55
55
  rescue ArgumentError, TypeError
56
56
  begin
57
- Date.iso8601(str_value).to_time
57
+ dt = Date.iso8601(str_value).to_time
58
+ # For compatibility, continue accepting dates given without times
59
+ # But without this, it would zero out given any time part of `str_value` (hours and/or minutes)
60
+ if dt.iso8601.start_with?(str_value)
61
+ dt
62
+ else
63
+ nil
64
+ end
58
65
  rescue ArgumentError, TypeError
59
66
  # Invalid input
60
67
  nil
@@ -83,7 +83,8 @@ module GraphQL
83
83
  end
84
84
 
85
85
  def visible?(ctx)
86
- node_type.visible?(ctx)
86
+ # if this is an abstract base class, there may be no `node_type`
87
+ node_type ? node_type.visible?(ctx) : super
87
88
  end
88
89
 
89
90
  # Set the default `node_nullable` for this class and its child classes. (Defaults to `true`.)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "1.13.5"
3
+ VERSION = "1.13.9"
4
4
  end
data/lib/graphql.rb CHANGED
@@ -17,6 +17,17 @@ module GraphQL
17
17
  class Error < StandardError
18
18
  end
19
19
 
20
+ # This error is raised when GraphQL-Ruby encounters a situation
21
+ # that it *thought* would never happen. Please report this bug!
22
+ class InvariantError < Error
23
+ def initialize(message)
24
+ message += "
25
+
26
+ This is probably a bug in GraphQL-Ruby, please report this error on GitHub: https://github.com/rmosolgo/graphql-ruby/issues/new?template=bug_report.md"
27
+ super(message)
28
+ end
29
+ end
30
+
20
31
  class RequiredImplementationMissingError < Error
21
32
  end
22
33
 
@@ -69,6 +80,7 @@ require "graphql/invalid_name_error"
69
80
  require "graphql/integer_decoding_error"
70
81
  require "graphql/integer_encoding_error"
71
82
  require "graphql/string_encoding_error"
83
+ require "graphql/date_encoding_error"
72
84
 
73
85
  require "graphql/define"
74
86
  require "graphql/base_type"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.5
4
+ version: 1.13.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-13 00:00:00.000000000 Z
11
+ date: 2022-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -245,11 +245,20 @@ files:
245
245
  - MIT-LICENSE
246
246
  - lib/generators/graphql/core.rb
247
247
  - lib/generators/graphql/enum_generator.rb
248
+ - lib/generators/graphql/field_extractor.rb
249
+ - lib/generators/graphql/input_generator.rb
250
+ - lib/generators/graphql/install/mutation_root_generator.rb
251
+ - lib/generators/graphql/install/templates/base_mutation.erb
252
+ - lib/generators/graphql/install/templates/mutation_type.erb
248
253
  - lib/generators/graphql/install_generator.rb
249
254
  - lib/generators/graphql/interface_generator.rb
250
255
  - lib/generators/graphql/loader_generator.rb
256
+ - lib/generators/graphql/mutation_create_generator.rb
257
+ - lib/generators/graphql/mutation_delete_generator.rb
251
258
  - lib/generators/graphql/mutation_generator.rb
259
+ - lib/generators/graphql/mutation_update_generator.rb
252
260
  - lib/generators/graphql/object_generator.rb
261
+ - lib/generators/graphql/orm_mutations_base.rb
253
262
  - lib/generators/graphql/relay.rb
254
263
  - lib/generators/graphql/relay_generator.rb
255
264
  - lib/generators/graphql/scalar_generator.rb
@@ -260,16 +269,18 @@ files:
260
269
  - lib/generators/graphql/templates/base_field.erb
261
270
  - lib/generators/graphql/templates/base_input_object.erb
262
271
  - lib/generators/graphql/templates/base_interface.erb
263
- - lib/generators/graphql/templates/base_mutation.erb
264
272
  - lib/generators/graphql/templates/base_object.erb
265
273
  - lib/generators/graphql/templates/base_scalar.erb
266
274
  - lib/generators/graphql/templates/base_union.erb
267
275
  - lib/generators/graphql/templates/enum.erb
268
276
  - lib/generators/graphql/templates/graphql_controller.erb
277
+ - lib/generators/graphql/templates/input.erb
269
278
  - lib/generators/graphql/templates/interface.erb
270
279
  - lib/generators/graphql/templates/loader.erb
271
280
  - lib/generators/graphql/templates/mutation.erb
272
- - lib/generators/graphql/templates/mutation_type.erb
281
+ - lib/generators/graphql/templates/mutation_create.erb
282
+ - lib/generators/graphql/templates/mutation_delete.erb
283
+ - lib/generators/graphql/templates/mutation_update.erb
273
284
  - lib/generators/graphql/templates/node_type.erb
274
285
  - lib/generators/graphql/templates/object.erb
275
286
  - lib/generators/graphql/templates/query_type.erb
@@ -323,6 +334,7 @@ files:
323
334
  - lib/graphql/dataloader/request.rb
324
335
  - lib/graphql/dataloader/request_all.rb
325
336
  - lib/graphql/dataloader/source.rb
337
+ - lib/graphql/date_encoding_error.rb
326
338
  - lib/graphql/define.rb
327
339
  - lib/graphql/define/assign_argument.rb
328
340
  - lib/graphql/define/assign_connection.rb
@@ -695,7 +707,7 @@ metadata:
695
707
  source_code_uri: https://github.com/rmosolgo/graphql-ruby
696
708
  bug_tracker_uri: https://github.com/rmosolgo/graphql-ruby/issues
697
709
  mailing_list_uri: https://tinyletter.com/graphql-ruby
698
- post_install_message:
710
+ post_install_message:
699
711
  rdoc_options: []
700
712
  require_paths:
701
713
  - lib
@@ -710,8 +722,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
710
722
  - !ruby/object:Gem::Version
711
723
  version: '0'
712
724
  requirements: []
713
- rubygems_version: 3.3.3
714
- signing_key:
725
+ rubygems_version: 3.1.6
726
+ signing_key:
715
727
  specification_version: 4
716
728
  summary: A GraphQL language and runtime for Ruby
717
729
  test_files: []