rspec-graphql_types 1.0.6 → 1.0.8
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 +1 -1
- data/lib/rspec/graphql_types/version.rb +1 -1
- data/lib/rspec/graphql_types.rb +46 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f6426d6eec64dd893caa0ca56e1dbb57df9b3798a2b6ef3ff2fef9fcb8a1c8f
|
4
|
+
data.tar.gz: 2876a66e0b1c2c94c5bee31d291f1787f05d656e3a7725179b08c4a945cd5641
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfd4fbc4a0e8b9accadd3e4fb8fe520705e01676aaba377dc1b03e56730856f5173982ad223c7ae86e749c44f6da0b6fc9ba1ac6ecbaef25ba7a332c9ab59ec8
|
7
|
+
data.tar.gz: 464e751ee2e321e63400dd28b1b2bded5f4bb8b92d14c5e1eababa7c104c6b3f699d70a5fb07883d8a97aa63b10393fff760628d741bb3bcedce73bf381056fa
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/lib/rspec/graphql_types.rb
CHANGED
@@ -9,23 +9,55 @@ module Rspec
|
|
9
9
|
extend ActiveSupport::Concern
|
10
10
|
|
11
11
|
class TestQuery < ::GraphQL::Query::NullContext::NullQuery
|
12
|
+
attr_reader :context, :schema, :multiplex
|
13
|
+
|
14
|
+
def initialize(context:, schema:)
|
15
|
+
super()
|
16
|
+
@context = context
|
17
|
+
@schema = schema
|
18
|
+
@multiplex = false
|
19
|
+
end
|
20
|
+
|
12
21
|
def trace(_key, _data)
|
13
22
|
yield
|
14
23
|
end
|
15
24
|
|
16
|
-
def
|
17
|
-
|
25
|
+
def handle_or_reraise(err)
|
26
|
+
schema.handle_or_reraise(context, err)
|
18
27
|
end
|
19
28
|
|
20
29
|
def warden
|
21
|
-
@warden
|
30
|
+
@warden ||= ::GraphQL::Query::NullContext::NullWarden.new(
|
31
|
+
::GraphQL::Filter.new,
|
32
|
+
context: context,
|
33
|
+
schema: schema
|
34
|
+
)
|
22
35
|
end
|
23
36
|
end
|
24
37
|
|
25
38
|
included do
|
26
39
|
let(:context_values) { nil }
|
27
40
|
let(:schema) { ::GraphQL::VERSION.start_with?("1") ? GraphQLTypes.schema_class.new : GraphQLTypes.schema_class }
|
28
|
-
let(:context) {
|
41
|
+
let(:context) {
|
42
|
+
::GraphQL::Query::Context.new(
|
43
|
+
query: TestQuery.new(context: self, schema: schema),
|
44
|
+
values: context_values,
|
45
|
+
object: nil,
|
46
|
+
schema: schema
|
47
|
+
)
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
class Configuration
|
52
|
+
attr_accessor :graphql_schema
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.configuration
|
56
|
+
@configuration ||= Configuration.new
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.configure
|
60
|
+
yield configuration
|
29
61
|
end
|
30
62
|
|
31
63
|
def graphql_object(type, value)
|
@@ -74,9 +106,17 @@ module Rspec
|
|
74
106
|
end
|
75
107
|
|
76
108
|
def self.schema_class
|
77
|
-
|
78
|
-
|
109
|
+
return configuration.graphql_schema if configuration.graphql_schema
|
110
|
+
|
111
|
+
schemas = find_graphql_schema
|
112
|
+
raise "Could not find valid schema. Found: #{schemas.join(", ")} Use Rspec::GraphQLTypes.configure to specify the correct schema" unless schemas.length == 1
|
79
113
|
schemas.first
|
80
114
|
end
|
115
|
+
|
116
|
+
def self.find_graphql_schema
|
117
|
+
::GraphQL::Schema.subclasses
|
118
|
+
.filter { |schema| !schema.name&.start_with?("GraphQL::") }
|
119
|
+
.filter { |schema| !schema.name&.ends_with?("::SCHEMA") }
|
120
|
+
end
|
81
121
|
end
|
82
122
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tejas Dinkar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|