rspec-graphql_types 1.0.2 → 1.0.5
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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +4 -3
- data/README.md +2 -4
- data/lib/rspec/graphql_types/version.rb +1 -1
- data/lib/rspec/graphql_types.rb +10 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71d9e4107a617bb6b00c6510139162fd5334b56bbc2bdba1969f8ea30570c204
|
4
|
+
data.tar.gz: 8a067ac01ce90d84db19807c907b95d40c1576b2a47ebdad96b0a88a4b6a7fa6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab7ebe43158db7914e77c84760b7f89caf3e943d1453abd9c0463ad03302f688c44a514b904e72b1f080f15901000f593c6bc53c1d1adda48a279e50cfa2b077
|
7
|
+
data.tar.gz: 7a7d5f28f2df92b424a27378800aed6c8349445aff0325b626facce4699d27522471126ab51e39f37556d897c6ccfb68680d8b47ea7e3d17ba0548279666b969
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rspec-graphql_types (1.0.
|
4
|
+
rspec-graphql_types (1.0.3)
|
5
5
|
activesupport
|
6
6
|
graphql
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (6.1.4)
|
11
|
+
activesupport (6.1.4.1)
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
13
|
i18n (>= 1.6, < 2)
|
14
14
|
minitest (>= 5.1)
|
@@ -16,7 +16,7 @@ GEM
|
|
16
16
|
zeitwerk (~> 2.3)
|
17
17
|
concurrent-ruby (1.1.9)
|
18
18
|
diff-lcs (1.4.4)
|
19
|
-
graphql (1.12.
|
19
|
+
graphql (1.12.16)
|
20
20
|
i18n (1.8.10)
|
21
21
|
concurrent-ruby (~> 1.0)
|
22
22
|
minitest (5.14.4)
|
@@ -40,6 +40,7 @@ GEM
|
|
40
40
|
|
41
41
|
PLATFORMS
|
42
42
|
arm64-darwin-20
|
43
|
+
x86_64-darwin-20
|
43
44
|
|
44
45
|
DEPENDENCIES
|
45
46
|
rake (~> 13.0)
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
# Rspec::
|
1
|
+
# Rspec::GraphQLTypes
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
This library can be used to unit test GraphQL types from the 'graphql' library.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
data/lib/rspec/graphql_types.rb
CHANGED
@@ -16,10 +16,15 @@ module Rspec
|
|
16
16
|
def multiplex
|
17
17
|
nil
|
18
18
|
end
|
19
|
+
|
20
|
+
def warden
|
21
|
+
@warden
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
25
|
included do
|
22
|
-
let(:
|
26
|
+
let(:context_values) { nil }
|
27
|
+
let(:context) { GraphQL::Query::Context.new(query: TestQuery.new, values: context_values, object: nil, schema: GraphQLTypes.schema_class.new) }
|
23
28
|
end
|
24
29
|
|
25
30
|
def graphql_object(type, value)
|
@@ -36,6 +41,8 @@ module Rspec
|
|
36
41
|
type.coerce_result(value, context)
|
37
42
|
when 'LIST'
|
38
43
|
value.map { |v| graphql_object(type.of_type, v) }
|
44
|
+
when 'ENUM'
|
45
|
+
type.coerce_result(value, context)
|
39
46
|
else
|
40
47
|
raise "Unknown type kind #{type.kind.name}"
|
41
48
|
end
|
@@ -49,6 +56,7 @@ module Rspec
|
|
49
56
|
value = context.dataloader.run_isolated do
|
50
57
|
graphql_field.resolve(object, arguments, context)
|
51
58
|
end
|
59
|
+
raise value if value.is_a?(Exception)
|
52
60
|
graphql_object(graphql_field.type, value)
|
53
61
|
end
|
54
62
|
|
@@ -65,7 +73,7 @@ module Rspec
|
|
65
73
|
end
|
66
74
|
|
67
75
|
def self.schema_class
|
68
|
-
schemas = GraphQL::Schema.subclasses
|
76
|
+
schemas = GraphQL::Schema.subclasses.filter { |schema| !schema.name.start_with?("GraphQL::") }
|
69
77
|
raise "Could not find valid schema. Please ensure that GraphQL::Schema.subclasses returns a single schema" unless schemas.length == 1
|
70
78
|
schemas.first
|
71
79
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-graphql_types
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tejas Dinkar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
|
-
rubygems_version: 3.2.
|
85
|
+
rubygems_version: 3.2.32
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: Test out types in ruby graphql
|