graphql-schema-directive-constraint 0.1.1 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54fdb88a40d5afae3b157debef6a265a6bcfc70b93173417a2be5f9384e89032
4
- data.tar.gz: 9449155280409521fcee3ba2030ee26f56b75651509def30ffc5fa0639641181
3
+ metadata.gz: 9474de7a5dcc0cfd75e6f5950751418a7c3cdf680d98a6e44daf872f7e3f3e33
4
+ data.tar.gz: 8c1feefb9dcb12a136caa168b1107a7c7bf57712cc87f8ad3e6f08703ca334b2
5
5
  SHA512:
6
- metadata.gz: 8e04ce8b3cc8e353400eed57f09daf1054bd373cce9db7a837606056e987b3695cbab5888f272a7011f67991751f643b60601d3d594c61eeb6d8de1a8bf30608
7
- data.tar.gz: 012e49f9ee323ff6bcac65db67bc3a81506ed28fec1b072ed40623bbbe61a47208aa1187b2a523d59d7d757d843562ae3de7287fa98d8c1cc96dc5b05fca5a7e
6
+ metadata.gz: 93a3a0802cbb6281da84c207c748f410e7a0e9609f70423a0832aab9073298c0d6171b270106f80761928f6433183c93bf91b1755c5c9c37269b5e2ca3e5467c
7
+ data.tar.gz: 2df0a5065089e369c0dbf10733e1aab1c243012a9d9621efd84caa29375d35f6ab254ff4b184fba6469a655a7da5dcf181258e95de010582d66325d728eb97ed
data/.rubocop.yml CHANGED
@@ -28,3 +28,9 @@ Lint/ConstantDefinitionInBlock:
28
28
 
29
29
  Metrics/BlockLength:
30
30
  Enabled: false
31
+
32
+ Metrics/CyclomaticComplexity:
33
+ Max: 14
34
+
35
+ Metrics/MethodLength:
36
+ Max: 25
data/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
- ## [Unreleased]
1
+ ## [0.2.0] - 2022-04-07
2
+
3
+ - Relax graphql version (support graphql-ruby 2.x) by @michiomochi
2
4
 
3
5
  ## [0.1.0] - 2022-02-06
4
6
 
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Allows using @constraint as a directive to validate input data for [graphql-ruby](https://graphql-ruby.org).
4
4
 
5
- This gem is heavealy inspired by [confuser/graphql-constraint-directive](https://github.com/confuser/graphql-constraint-directive)
5
+ This gem is greatly inspired by [confuser/graphql-constraint-directive](https://github.com/confuser/graphql-constraint-directive)
6
6
 
7
7
  ## Installation
8
8
 
@@ -93,18 +93,18 @@ This example only generates `@constraint` directive on schema but it does not va
93
93
  - [x] constraint
94
94
  - [ ] validator
95
95
  - [ ] Integer
96
- - [ ] min
97
- - [ ] constraint
98
- - [ ] validator
99
- - [ ] max
100
- - [ ] constraint
101
- - [ ] validator
102
- - [ ] exclusiveMin
103
- - [ ] constraint
104
- - [ ] validator
105
- - [ ] exclusiveMax
106
- - [ ] constraint
107
- - [ ] validator
96
+ - [x] min
97
+ - [x] constraint
98
+ - [x] validator
99
+ - [x] max
100
+ - [x] constraint
101
+ - [x] validator
102
+ - [x] exclusiveMin
103
+ - [x] constraint
104
+ - [x] validator
105
+ - [x] exclusiveMax
106
+ - [x] constraint
107
+ - [x] validator
108
108
  - [ ] multipleOf
109
109
  - [ ] constraint
110
110
  - [ ] validator
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "graphql-schema-directive-constraint"
5
- spec.version = "0.1.1"
5
+ spec.version = "0.3.0"
6
6
  spec.authors = ["Ryota Yoshikawa"]
7
7
  spec.email = ["yoshikawa@topotal.com"]
8
8
 
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.require_paths = ["lib"]
33
33
 
34
34
  # Uncomment to register a new dependency of your gem
35
- spec.add_dependency "graphql", "~> 1.0"
35
+ spec.add_dependency "graphql", "~> 2.0"
36
36
 
37
37
  spec.add_development_dependency "rake", "~> 13.0"
38
38
  spec.add_development_dependency "rspec", "~> 3.0"
@@ -32,6 +32,12 @@ module GraphQL
32
32
  argument(:pattern, String, description: "Ensure value matches regex, e.g. alphanumeric", required: false)
33
33
  argument(:format, String, description: "Ensure value is in a particular format", required: false)
34
34
 
35
+ argument(:min, Integer, description: "Ensure value is greater than or equal to", required: false)
36
+ argument(:max, Integer, description: "Ensure value is less than or equal to", required: false)
37
+ argument(:exclusiveMin, Integer, description: "Ensure value is greater than", required: false)
38
+ argument(:exclusiveMax, Integer, description: "Ensure value is less than", required: false)
39
+ argument(:multipleOf, Integer, description: "Ensure value is a multiple", required: false)
40
+
35
41
  argument(:without_validator, Boolean, description: "Use constraint directive without validator", required: false)
36
42
 
37
43
  locations(
@@ -53,6 +59,14 @@ module GraphQL
53
59
  owner.validates({ length: { maximum: maxLength } })
54
60
  in [:pattern, pattern]
55
61
  owner.validates({ format: { with: pattern } })
62
+ in [:min, min]
63
+ owner.validates({ numericality: { greater_than_or_equal_to: min } })
64
+ in [:max, max]
65
+ owner.validates({ numericality: { less_than_or_equal_to: max } })
66
+ in [:exclusiveMin, exclusiveMin]
67
+ owner.validates({ numericality: { greater_than: exclusiveMin } })
68
+ in [:exclusiveMax, exclusiveMax]
69
+ owner.validates({ numericality: { less_than: exclusiveMax } })
56
70
  else
57
71
  raise NotImplementedError("Given arguments are not implemented yet")
58
72
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-schema-directive-constraint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Yoshikawa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-07 00:00:00.000000000 Z
11
+ date: 2023-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  requirements: []
112
- rubygems_version: 3.2.32
112
+ rubygems_version: 3.2.33
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Allows using @constraint as a directive to validate input data.