rails-graphql 1.0.0.rc2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c29232c14870c44aeab62fba29beda42f8f99a8047bf83f717149e6fc2e5d7c
4
- data.tar.gz: 196468f3151958620774998650fe7a5f70e0b3204fdb5a028b31c634d21a9cb0
3
+ metadata.gz: 38fafc81ae4e9f8c11c4d1495b8290656dcf388ac0b6d5536829e0f77ee09bb2
4
+ data.tar.gz: 8a8298e375df5ac6905b24deeacf29ca2fd7b4dc39dfb43601ba2331828ac939
5
5
  SHA512:
6
- metadata.gz: a17d0f98a0473afd6d221d98b967068ae9d97da363e44e92817729e23a204510768c72bed50a858816e9d7eeda8b0fcdefe83c56d9782e8abe06d71bea6e0f75
7
- data.tar.gz: c4258dfce30c7aedba8a3f2c1a9a6c20b0eca30ae520888efac8dfeb3f5267654d74e2992b9794bdb892a2f84d8f1be68d6d71e637ebaa48ee780d3b019ccf25
6
+ metadata.gz: fa92f53a2111c001863967bca893a25bab09f9a9c163af945631a15054c865db2e9102467e8c85ac1c3cbc0591c377a97f98c2439bdc94c72694d72cbef99e05
7
+ data.tar.gz: d994c9ff91179fbd72ecb3afde6f3bb005805697ebe994cfcc88b2bc9720e30f16ac76f6dab81b65760ad3e61af5db427d9a5e9118f6222b756df00c35b499d7
data/Rakefile CHANGED
@@ -2,7 +2,7 @@
2
2
  # Rake tasks for development purposes
3
3
 
4
4
  begin
5
- require 'bundler/setup'
5
+ require 'bundler/setup' unless ENV.key?('CI_COMPILE')
6
6
  rescue LoadError
7
7
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
8
8
  end
data/lib/gql_parser.so CHANGED
Binary file
@@ -61,6 +61,11 @@ module Rails
61
61
  # different suffix, change this value to it.
62
62
  config.auto_suffix_input_objects = 'Input'
63
63
 
64
+ # Set if the server should allow strings be used as input for ENUM inputs.
65
+ # It means that operations will support quotes for ENUM values embedded in
66
+ # the documents (heredoc won't be accepted).
67
+ config.allow_string_as_enum_input = false
68
+
64
69
  # Introspection is enabled by default. It is recommended to only use
65
70
  # introspection during development and tests, never in production.
66
71
  # This can also be set per schema level.
@@ -39,7 +39,9 @@ module Rails
39
39
  # Check if a given value is a valid non-deserialized input
40
40
  def valid_input?(value)
41
41
  (valid_token?(value, :enum) && all_values.include?(value.to_s)) ||
42
- (value.is_a?(String) && all_values.include?(value))
42
+ (value.is_a?(String) && all_values.include?(value)) ||
43
+ (allow_string_input? && valid_token?(value, :string) &&
44
+ all_values.include?(value.to_s[1..-2]))
43
45
  end
44
46
 
45
47
  # Check if a given value is a valid non-serialized output
@@ -62,7 +64,13 @@ module Rails
62
64
 
63
65
  # Turn a user input of this given type into an ruby object
64
66
  def deserialize(value)
65
- new(value.is_a?(::GQLParser::Token) ? value.to_s : value) if valid_input?(value)
67
+ if valid_token?(value, :enum)
68
+ new(value.to_s)
69
+ elsif allow_string_input? && valid_token?(value, :string)
70
+ new(value[1..-2])
71
+ elsif valid_input?(value)
72
+ new(value)
73
+ end
66
74
  end
67
75
 
68
76
  # Use the instance as decorator
@@ -142,6 +150,12 @@ module Rails
142
150
  #{inspect_directives}
143
151
  INFO
144
152
  end
153
+
154
+ private
155
+
156
+ def allow_string_input?
157
+ GraphQL.config.allow_string_as_enum_input
158
+ end
145
159
  end
146
160
 
147
161
  attr_reader :value
@@ -15,7 +15,7 @@ module Rails
15
15
  MAJOR = 1
16
16
  MINOR = 0
17
17
  TINY = 0
18
- PRE = 'rc2'
18
+ PRE = nil
19
19
 
20
20
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
21
21
  end
@@ -17,6 +17,13 @@ class GraphQL_Type_EnumTest < GraphQL::TestCase
17
17
  refute(DESCRIBED_CLASS.valid_input?(1))
18
18
  refute(DESCRIBED_CLASS.valid_input?(nil))
19
19
  refute(DESCRIBED_CLASS.valid_input?('abc'))
20
+
21
+ str_token = new_token('"A"', :string)
22
+ refute(DESCRIBED_CLASS.valid_input?(str_token))
23
+
24
+ stubbed_config(:allow_string_as_enum_input, true) do
25
+ assert(DESCRIBED_CLASS.valid_input?(str_token))
26
+ end
20
27
  end
21
28
 
22
29
  def test_valid_output_ask
@@ -58,6 +65,14 @@ class GraphQL_Type_EnumTest < GraphQL::TestCase
58
65
  test_value = DESCRIBED_CLASS.deserialize('A')
59
66
  assert_instance_of(DESCRIBED_CLASS, test_value)
60
67
  assert_equal('A', test_value.value)
68
+
69
+ str_token = new_token('"A"', :string)
70
+ assert_nil(DESCRIBED_CLASS.deserialize(str_token))
71
+ stubbed_config(:allow_string_as_enum_input, true) do
72
+ test_value = DESCRIBED_CLASS.deserialize(str_token)
73
+ assert_instance_of(DESCRIBED_CLASS, test_value)
74
+ assert_equal('A', test_value.value)
75
+ end
61
76
  end
62
77
 
63
78
  def test_decorate
@@ -10,6 +10,7 @@ class MySQLRecord < ActiveRecord::Base
10
10
  database: ENV.fetch('GQL_MYSQL_DATABASE', 'starwars'),
11
11
  username: ENV.fetch('GQL_MYSQL_USERNAME', 'root'),
12
12
  password: ENV['GQL_MYSQL_PASSWORD'],
13
+ port: ENV['GQL_MYSQL_PORT'],
13
14
  )
14
15
  end
15
16
 
data/test/test_ext.rb CHANGED
@@ -1,6 +1,12 @@
1
1
  # Core ext methods
2
2
 
3
3
  class Object < BasicObject
4
+ def new_token(value, type)
5
+ GQLParser::Token.new(value).tap do |token|
6
+ token.instance_variable_set(:@type, type)
7
+ end
8
+ end
9
+
4
10
  def stub_ivar(name, value = nil)
5
11
  instance_variable_set(name, value)
6
12
  yield
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Silva
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-28 00:00:00.000000000 Z
11
+ date: 2023-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -414,9 +414,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
414
414
  version: 2.6.3
415
415
  required_rubygems_version: !ruby/object:Gem::Requirement
416
416
  requirements:
417
- - - ">"
417
+ - - ">="
418
418
  - !ruby/object:Gem::Version
419
- version: 1.3.1
419
+ version: '0'
420
420
  requirements: []
421
421
  rubygems_version: 3.3.26
422
422
  signing_key: