artemis 1.0.0 → 1.0.2

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: 67885289ab96c6ee04586b1c448bfa3832ecdb6b8ce2b28726d988a24801aee4
4
- data.tar.gz: 788127f71e696536fd2f6e2076f97f2bb8af6d9374af5760782da12c85005660
3
+ metadata.gz: 48a7d1c38990ead32932786f4a3981d3e7a8db1914ffac704bd14fec1511e9a6
4
+ data.tar.gz: 6a3150492d60d3f94baff965a514b2392c0bdfc9c34d51cca540b7156cf4b1ba
5
5
  SHA512:
6
- metadata.gz: e4099922005bf7f838d9e6147253b8403b9381fa5ea7c29a1317045b64c8cbe08e2bcc8ea0060ff60da41b7fba9325f47cce079ae1c8d217d0d47dcfee437c5f
7
- data.tar.gz: f633c25ba1ddbe8bcec167425f4f48b9ed8d6f94bac6048dc75c9a68bb13745af76b4572bb1b4e3a869bbf542a0928c8a0235e9ee835726e52325085e089d42b
6
+ metadata.gz: 594a2346bfc01cf7d8ca53c7359693f4e43e38dea0a5e65d36faf51851a55665839436078b7d1aaf6a20441edb949e24f0f406c0612928f00c850e552d4e829d
7
+ data.tar.gz: 9a19609908348342985afa0ef74e40133b1ea647fed58279b8c11efbc27e257e1086290932c3af2c0083c40cd0d5baa8b746929533c3d8f2a58d05ce1de4c0ab
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## v1.0.2
2
+
3
+ #### 🐞 Bug Fixes
4
+
5
+ - Fixes a bug where abstract client classes are not loaded correctly (#93, `494d30b`)
6
+
7
+ ## v1.0.1
8
+
9
+ > Yanked due to inconsistent commit history.
10
+
1
11
  ## v1.0.0
2
12
 
3
13
  #### 🚨 Breaking Changes
data/Rakefile CHANGED
@@ -1,6 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
- require 'rspec/core/rake_task'
4
3
 
5
4
  TESTS_IN_ISOLATION = ['test/railtie_test.rb', 'test/rake_tasks_test.rb']
6
5
 
@@ -16,6 +15,4 @@ Rake::TestTask.new('test:isolated') do |t|
16
15
  t.warning = false
17
16
  end
18
17
 
19
- RSpec::Core::RakeTask.new(:spec)
20
-
21
- task default: ['spec', 'test', 'test:isolated']
18
+ task default: ['test', 'test:isolated']
data/artemis.gemspec CHANGED
@@ -24,5 +24,4 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "bundler", ">= 1.16"
25
25
  spec.add_development_dependency "net-http-persistent", ">= 3.0"
26
26
  spec.add_development_dependency "rake", ">= 10.0"
27
- spec.add_development_dependency "rspec", ">= 3.8"
28
27
  end
@@ -31,7 +31,9 @@ module Artemis
31
31
  end
32
32
 
33
33
  initializer 'graphql.client.set_reloader', after: 'graphql.client.set_query_paths' do |app|
34
- if !config.respond_to?(:autoloader) || config.autoloader != :zeitwerk
34
+ not_on_zeitwerk = !defined?(Zeitwerk) || (app.config.respond_to?(:autoloader) && app.config.autoloader != :zeitwerk)
35
+
36
+ if not_on_zeitwerk
35
37
  files_to_watch = Artemis::Client.query_paths.map {|path| [path, config.artemis.graphql_extentions] }.to_h
36
38
 
37
39
  app.reloaders << ActiveSupport::FileUpdateChecker.new([], files_to_watch) do
@@ -58,14 +60,10 @@ module Artemis
58
60
  end
59
61
 
60
62
  initializer 'graphql.client.preload', after: 'graphql.client.load_config' do |app|
61
- if app.config.eager_load && app.config.cache_classes
62
- Artemis::GraphQLEndpoint.registered_services.each do |endpoint_name|
63
- begin
64
- require_dependency endpoint_name # Rails 7.0+ requires this.
65
- rescue LoadError
66
- # no-op...
67
- end
63
+ not_on_zeitwerk = !defined?(Zeitwerk) || (app.config.respond_to?(:autoloader) && app.config.autoloader != :zeitwerk)
68
64
 
65
+ if app.config.eager_load && app.config.cache_classes && not_on_zeitwerk
66
+ Artemis::GraphQLEndpoint.registered_services.each do |endpoint_name|
69
67
  endpoint_name.camelize.constantize.preload!
70
68
  end
71
69
  end
@@ -1,3 +1,3 @@
1
1
  module Artemis
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artemis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Allured
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-02-05 00:00:00.000000000 Z
12
+ date: 2024-05-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -123,20 +123,6 @@ dependencies:
123
123
  - - ">="
124
124
  - !ruby/object:Gem::Version
125
125
  version: '10.0'
126
- - !ruby/object:Gem::Dependency
127
- name: rspec
128
- requirement: !ruby/object:Gem::Requirement
129
- requirements:
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- version: '3.8'
133
- type: :development
134
- prerelease: false
135
- version_requirements: !ruby/object:Gem::Requirement
136
- requirements:
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- version: '3.8'
140
126
  description: GraphQL client on Rails + Convention over Configuration = ❤️
141
127
  email:
142
128
  - jon.allured@gmail.com
@@ -198,22 +184,6 @@ files:
198
184
  - lib/generators/artemis/query/templates/fixture.yml
199
185
  - lib/generators/artemis/query/templates/query.graphql
200
186
  - lib/tasks/artemis.rake
201
- - spec/adapters_spec.rb
202
- - spec/autoloading_spec.rb
203
- - spec/callbacks_spec.rb
204
- - spec/client_spec.rb
205
- - spec/endpoint_spec.rb
206
- - spec/fixtures/github.rb
207
- - spec/fixtures/github/_repository_fields.graphql
208
- - spec/fixtures/github/repository.graphql
209
- - spec/fixtures/github/schema.json
210
- - spec/fixtures/github/user.graphql
211
- - spec/fixtures/github/user_repositories.graphql
212
- - spec/fixtures/responses/github/repository.yml
213
- - spec/fixtures/responses/github/user.json
214
- - spec/fixtures/responses/spotify_client/artist.yml
215
- - spec/spec_helper.rb
216
- - spec/test_helper_spec.rb
217
187
  - tmp/.gitkeep
218
188
  homepage: https://github.com/yuki24/artemis
219
189
  licenses:
@@ -234,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
204
  - !ruby/object:Gem::Version
235
205
  version: '0'
236
206
  requirements: []
237
- rubygems_version: 3.5.3
207
+ rubygems_version: 3.5.9
238
208
  signing_key:
239
209
  specification_version: 4
240
210
  summary: GraphQL on Rails
@@ -1,278 +0,0 @@
1
- require 'json'
2
- require 'rack'
3
- require 'webrick'
4
-
5
- RACK_SERVER = begin
6
- require 'rackup/handler/webrick'
7
- Rackup::Handler::WEBrick
8
- rescue LoadError
9
- Rack::Handler::WEBrick
10
- end
11
-
12
- describe 'Adapters' do
13
- FakeServer = ->(env) {
14
- case env['PATH_INFO']
15
- when '/slow_server'
16
- sleep 2.1
17
-
18
- [200, {}, ['{}']]
19
- when '/500'
20
- [500, {}, ['Server error']]
21
- when '/test_multi_domain'
22
- body = {
23
- data: {
24
- body: "Endpoint switched.",
25
- headers: env.select {|key, val| key.match("^HTTP.*|^CONTENT.*|^AUTHORIZATION.*") }
26
- .collect {|key, val| [key.gsub(/^HTTP_/, ''), val.downcase] }
27
- .to_h,
28
- },
29
- errors: [],
30
- extensions: {}
31
- }.to_json
32
-
33
- [200, {}, [body]]
34
- else
35
- request_body = JSON.parse(env['rack.input'].read)
36
-
37
- response_body = if request_body['_json']
38
- request_body['_json'].map do |query|
39
- {
40
- data: {
41
- body: query,
42
- headers: env.select {|key, val| key.match("^HTTP.*|^CONTENT.*|^AUTHORIZATION.*") }
43
- .collect {|key, val| [key.gsub(/^HTTP_/, ''), val.downcase] }
44
- .to_h,
45
- },
46
- errors: [],
47
- extensions: {}
48
- }
49
- end.to_json
50
- else
51
- {
52
- data: {
53
- body: request_body,
54
- headers: env.select {|key, val| key.match("^HTTP.*|^CONTENT.*|^AUTHORIZATION.*") }
55
- .collect {|key, val| [key.gsub(/^HTTP_/, ''), val.downcase] }
56
- .to_h,
57
- },
58
- errors: [],
59
- extensions: {}
60
- }.to_json
61
- end
62
-
63
- [200, {}, [response_body]]
64
- end
65
- }
66
-
67
- before :all do
68
- Artemis::Adapters::AbstractAdapter.send(:attr_writer, :uri, :timeout)
69
-
70
- @server_thread = Thread.new do
71
- RACK_SERVER.run(FakeServer, Port: 8000, Logger: WEBrick::Log.new('/dev/null'), AccessLog: [])
72
- end
73
-
74
- loop do
75
- begin
76
- TCPSocket.open('localhost', 8000)
77
- break
78
- rescue Errno::ECONNREFUSED
79
- # no-op
80
- end
81
- end
82
- end
83
-
84
- after :all do
85
- RACK_SERVER.shutdown
86
- @server_thread.terminate
87
- end
88
-
89
- shared_examples 'an adapter' do
90
- describe '#initialize' do
91
- it 'requires an url' do
92
- expect do
93
- adapter.class.new(nil, service_name: nil, timeout: 2, pool_size: 5)
94
- end.to raise_error(ArgumentError, "url is required (given `nil')")
95
- end
96
- end
97
-
98
- describe '#execute' do
99
- it 'makes an actual HTTP request' do
100
- response = adapter.execute(
101
- document: GraphQL::Client::IntrospectionDocument,
102
- operation_name: 'IntrospectionQuery',
103
- variables: { id: 'yayoi-kusama' },
104
- context: { user_id: 1 }
105
- )
106
-
107
- expect(response['data']['body']['query']).to eq(GraphQL::Client::IntrospectionDocument.to_query_string)
108
- expect(response['data']['body']['variables']).to eq('id' => 'yayoi-kusama')
109
- expect(response['data']['body']['operationName']).to eq('IntrospectionQuery')
110
- expect(response['data']['headers']['CONTENT_TYPE']).to eq('application/json')
111
- expect(response['data']['headers']['ACCEPT']).to eq('application/json')
112
- expect(response['errors']).to eq([])
113
- expect(response['extensions']).to eq({})
114
- end
115
-
116
- it 'raises an error when it receives a server error' do
117
- adapter.uri = URI.parse('http://localhost:8000/500')
118
-
119
- expect do
120
- adapter.execute(document: GraphQL::Client::IntrospectionDocument, operation_name: 'IntrospectionQuery')
121
- end.to raise_error(Artemis::GraphQLServerError, "Received server error status 500: Server error")
122
- end
123
-
124
- it 'allows for overriding timeout' do
125
- adapter.uri = URI.parse('http://localhost:8000/slow_server')
126
-
127
- expect do
128
- adapter.execute(document: GraphQL::Client::IntrospectionDocument, operation_name: 'IntrospectionQuery')
129
- end.to raise_error(timeout_error)
130
- end
131
- end
132
-
133
- describe '#multiplex' do
134
- it 'makes an HTTP request with multiple queries' do
135
- response = adapter.multiplex(
136
- [
137
- {
138
- query: GraphQL::Client::IntrospectionDocument.to_query_string,
139
- operationName: 'IntrospectionQuery',
140
- variables: {
141
- id: 'yayoi-kusama'
142
- },
143
- },
144
- ],
145
- context: {
146
- user_id: 1
147
- }
148
- )
149
-
150
- introspection_query = response[0]
151
-
152
- expect(introspection_query['data']['body']['query']).to eq(GraphQL::Client::IntrospectionDocument.to_query_string)
153
- expect(introspection_query['data']['body']['variables']).to eq('id' => 'yayoi-kusama')
154
- expect(introspection_query['data']['body']['operationName']).to eq('IntrospectionQuery')
155
- expect(introspection_query['data']['headers']['CONTENT_TYPE']).to eq('application/json')
156
- expect(introspection_query['data']['headers']['ACCEPT']).to eq('application/json')
157
- expect(introspection_query['errors']).to eq([])
158
- expect(introspection_query['extensions']).to eq({})
159
- end
160
-
161
- it 'raises an error when it receives a server error' do
162
- adapter.uri = URI.parse('http://localhost:8000/500')
163
-
164
- expect do
165
- adapter.multiplex([])
166
- end.to raise_error(Artemis::GraphQLServerError, "Received server error status 500: Server error")
167
- end
168
-
169
- it 'allows for overriding timeout' do
170
- adapter.uri = URI.parse('http://localhost:8000/slow_server')
171
-
172
- expect do
173
- adapter.multiplex([])
174
- end.to raise_error(timeout_error)
175
- end
176
- end
177
- end
178
-
179
- describe Artemis::Adapters::NetHttpAdapter do
180
- let(:adapter) { Artemis::Adapters::NetHttpAdapter.new('http://localhost:8000', service_name: nil, timeout: 0.5, pool_size: 5) }
181
- let(:timeout_error) { Net::ReadTimeout }
182
-
183
- it_behaves_like 'an adapter'
184
- end
185
-
186
- describe Artemis::Adapters::NetHttpPersistentAdapter do
187
- let(:adapter) { Artemis::Adapters::NetHttpPersistentAdapter.new('http://localhost:8000', service_name: nil, timeout: 0.5, pool_size: 5) }
188
- let(:timeout_error) { Net::ReadTimeout }
189
-
190
- it_behaves_like 'an adapter'
191
- end
192
-
193
- describe Artemis::Adapters::MultiDomainAdapter do
194
- let(:adapter) { Artemis::Adapters::MultiDomainAdapter.new('ignored', service_name: nil, timeout: 0.5, pool_size: 5, adapter_options: { adapter: :net_http }) }
195
-
196
- it 'makes an actual HTTP request' do
197
- response = adapter.execute(document: GraphQL::Client::IntrospectionDocument, context: { url: 'http://localhost:8000/test_multi_domain' })
198
-
199
- expect(response['data']['body']).to eq("Endpoint switched.")
200
- expect(response['errors']).to eq([])
201
- expect(response['extensions']).to eq({})
202
- end
203
-
204
- it 'can make a multiplex (the graphql feature, not HTTP/2) request' do
205
- response = adapter.multiplex(
206
- [
207
- {
208
- query: GraphQL::Client::IntrospectionDocument.to_query_string,
209
- operationName: 'IntrospectionQuery',
210
- variables: {
211
- id: 'yayoi-kusama'
212
- },
213
- },
214
- ],
215
- context: {
216
- url: 'http://localhost:8000/test_multi_domain'
217
- }
218
- )
219
-
220
- expect(response['data']['body']).to eq("Endpoint switched.")
221
- expect(response['errors']).to eq([])
222
- expect(response['extensions']).to eq({})
223
- end
224
-
225
- it 'can make a multiplex request with custom HTTP headers' do
226
- response = adapter.multiplex(
227
- [
228
- {
229
- query: GraphQL::Client::IntrospectionDocument.to_query_string,
230
- operationName: 'IntrospectionQuery',
231
- },
232
- ],
233
- context: {
234
- headers: {
235
- Authorization: "Token token",
236
- },
237
- url: 'http://localhost:8000/test_multi_domain'
238
- }
239
- )
240
-
241
- expect(response['data']['headers']['AUTHORIZATION']).to eq("token token")
242
- end
243
-
244
- it 'raises an error when adapter_options.adapter is set to :multi domain' do
245
- expect do
246
- Artemis::Adapters::MultiDomainAdapter.new('ignored', service_name: nil, timeout: 0.5, pool_size: 5, adapter_options: { adapter: :multi_domain })
247
- end.to raise_error(ArgumentError, 'You can not use the :multi_domain adapter with the :multi_domain adapter.')
248
- end
249
-
250
- it 'raises an error when context.url is not specified' do
251
- expect do
252
- adapter.execute(document: GraphQL::Client::IntrospectionDocument)
253
- end.to raise_error(ArgumentError, 'The MultiDomain adapter requires a url on every request. Please specify a ' \
254
- 'url with a context: Client.with_context(url: "https://awesomeshop.domain.conm")')
255
- end
256
-
257
- it 'raises an error when it receives a server error' do
258
- expect do
259
- adapter.execute(document: GraphQL::Client::IntrospectionDocument, context: { url: 'http://localhost:8000/500' })
260
- end.to raise_error(Artemis::GraphQLServerError, "Received server error status 500: Server error")
261
- end
262
-
263
- it 'allows for overriding timeout' do
264
- expect do
265
- adapter.execute(document: GraphQL::Client::IntrospectionDocument, context: { url: 'http://localhost:8000/slow_server' })
266
- end.to raise_error(Net::ReadTimeout)
267
- end
268
- end
269
-
270
- if RUBY_ENGINE == 'ruby'
271
- describe Artemis::Adapters::CurbAdapter do
272
- let(:adapter) { Artemis::Adapters::CurbAdapter.new('http://localhost:8000', service_name: nil, timeout: 2, pool_size: 5) }
273
- let(:timeout_error) { Curl::Err::TimeoutError }
274
-
275
- it_behaves_like 'an adapter'
276
- end
277
- end
278
- end
@@ -1,152 +0,0 @@
1
- describe "#{GraphQL::Client} Autoloading" do
2
- describe ".load_constant" do
3
- it "loads the specified constant if there is a matching graphql file" do
4
- Github.send(:remove_const, :User) if Github.constants.include?(:User)
5
-
6
- Github.load_constant(:User)
7
-
8
- expect(defined?(Github::User)).to eq('constant')
9
- end
10
-
11
- it "does nothing and returns nil if there is no matching file" do
12
- expect(Github.load_constant(:DoesNotExist)).to be_nil
13
- end
14
- end
15
-
16
- describe ".preload!" do
17
- it "preloads all the graphQL files in the query paths" do
18
- %i(User UserRepositories Repository RepositoryFields)
19
- .select {|const_name| Github.constants.include?(const_name) }
20
- .each {|const_name| Github.send(:remove_const, const_name) }
21
-
22
- Github.preload!
23
-
24
- expect(defined?(Github::User)).to eq('constant')
25
- expect(defined?(Github::Repository)).to eq('constant')
26
- end
27
- end
28
-
29
- it "dynamically loads the matching GraphQL query and sets it to a constant" do
30
- Github.send(:remove_const, :User) if Github.constants.include?(:User)
31
-
32
- query = Github::User
33
-
34
- expect(query.document.to_query_string).to eq(<<~GRAPHQL.strip)
35
- query Github__User {
36
- user(login: "yuki24") {
37
- id
38
- name
39
- }
40
- }
41
- GRAPHQL
42
- end
43
-
44
- it "dynamically loads the matching GraphQL fragment and sets it to a constant" do
45
- Github.send(:remove_const, :RepositoryFields) if Github.constants.include?(:RepositoryFields)
46
-
47
- query = Github::RepositoryFields
48
-
49
- expect(query.document.to_query_string).to eq(<<~GRAPHQL.strip)
50
- fragment Github__RepositoryFields on Repository {
51
- name
52
- nameWithOwner
53
- url
54
- updatedAt
55
- languages(first: 1) {
56
- nodes {
57
- name
58
- color
59
- }
60
- }
61
- }
62
- GRAPHQL
63
- end
64
-
65
- it "correctly loads the matching GraphQL query even when the top-level constant with the same name exists" do
66
- # In Ruby <= 2.4 top-level constants can be looked up through a namespace, which turned out to be a bad practice.
67
- # This has been removed in 2.5, but in earlier versions still suffer from this behaviour.
68
- Github.send(:remove_const, :User) if Github.constants.include?(:User)
69
- Object.send(:remove_const, :User) if Object.constants.include?(:User)
70
-
71
- begin
72
- Object.send(:const_set, :User, 1)
73
-
74
- Github.user
75
- ensure
76
- Object.send(:remove_const, :User)
77
- end
78
-
79
- query = Github::User
80
-
81
- expect(query.document.to_query_string).to eq(<<~GRAPHQL.strip)
82
- query Github__User {
83
- user(login: "yuki24") {
84
- id
85
- name
86
- }
87
- }
88
- GRAPHQL
89
- end
90
-
91
- it "raises an exception when the path was resolved but the file does not exist" do
92
- begin
93
- Github.graphql_file_paths << "github/removed.graphql"
94
-
95
- expect { Github::Removed }.to raise_error(Errno::ENOENT)
96
- ensure
97
- Github.graphql_file_paths.delete("github/removed.graphql")
98
- end
99
- end
100
-
101
- it "raises an NameError when there is no graphql file that matches the const name" do
102
- expect { Github::DoesNotExist }.to raise_error(NameError)
103
- end
104
-
105
- xit "defines the query method when the matching class method gets called for the first time" do
106
- Github.undef_method(:user) if Github.public_instance_methods.include?(:user)
107
-
108
- Github.user
109
-
110
- expect(Github.public_instance_methods).to include(:user)
111
- end
112
-
113
- it "raises an NameError when there is no graphql file that matches the class method name" do
114
- expect { Github.does_not_exist }.to raise_error(NameError)
115
- end
116
-
117
- it "raises an NameError when the class method name matches a fragment name" do
118
- expect { Github.repository_fields_fragment }.to raise_error(NameError)
119
- end
120
-
121
- it "responds to a class method that has a matching graphQL file" do
122
- expect(Github).to respond_to(:user)
123
- end
124
-
125
- it "does not respond to class methods that do not have a matching graphQL file" do
126
- expect(Github).not_to respond_to(:does_not_exist)
127
- end
128
-
129
- xit "defines the query method when the matching instance method gets called for the first time" do
130
- Github.undef_method(:user) if Github.public_instance_methods.include?(:user)
131
-
132
- Github.new.user
133
-
134
- expect(Github.public_instance_methods).to include(:user)
135
- end
136
-
137
- it "raises an NameError when there is no graphql file that matches the instance method name" do
138
- expect { Github.new.does_not_exist }.to raise_error(NameError)
139
- end
140
-
141
- it "raises an NameError when the instance method name matches a fragment name" do
142
- expect { Github.new.repository_fields_fragment }.to raise_error(NameError)
143
- end
144
-
145
- it "responds to the method that has a matching graphQL file" do
146
- expect(Github.new).to respond_to(:user)
147
- end
148
-
149
- it "does not respond to methods that do not have a matching graphQL file" do
150
- expect(Github.new).not_to respond_to(:does_not_exist)
151
- end
152
- end
@@ -1,60 +0,0 @@
1
- require 'active_support/core_ext/module/attribute_accessors'
2
-
3
- describe "#{GraphQL::Client} Callbacks" do
4
- Client = Class.new(Artemis::Client) do
5
- def self.name
6
- 'Github'
7
- end
8
-
9
- mattr_accessor :before_callback, :after_callback
10
- self.before_callback = nil
11
- self.after_callback = nil
12
-
13
- before_execute do |document, operation_name, variables, context|
14
- self.before_callback = document, operation_name, variables, context
15
- end
16
-
17
- after_execute do |data, errors, extensions|
18
- self.after_callback = data, errors, extensions
19
- end
20
- end
21
-
22
- Spotify = Class.new(Artemis::Client) do
23
- def self.name
24
- 'Spotify'
25
- end
26
-
27
- before_execute do
28
- raise "this callback should not get invoked"
29
- end
30
-
31
- after_execute do
32
- raise "this callback should not get invoked"
33
- end
34
- end
35
-
36
- describe ".before_execute" do
37
- it "gets invoked before executing" do
38
- Client.repository(owner: "yuki24", name: "artemis", context: { user_id: 'yuki24' })
39
-
40
- document, operation_name, variables, context = Client.before_callback
41
-
42
- expect(document).to eq(Client::Repository.document)
43
- expect(operation_name).to eq('Client__Repository')
44
- expect(variables).to eq("name" => "artemis", "owner" => "yuki24")
45
- expect(context).to eq(user_id: 'yuki24')
46
- end
47
- end
48
-
49
- describe ".after_execute" do
50
- it "gets invoked after executing" do
51
- Client.user
52
-
53
- data, errors, extensions = Client.after_callback
54
-
55
- expect(data).to eq("test" => "data")
56
- expect(errors).to eq([])
57
- expect(extensions).to eq({})
58
- end
59
- end
60
- end