Skip to content

Commit

Permalink
Fix: add backwards compatibility for clients without public config
Browse files Browse the repository at this point in the history
  • Loading branch information
povilasjurcys committed Dec 12, 2024
1 parent 2b02e26 commit 83b5927
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/active_graphql/client/actions/action/format_inputs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def call
attr_reader :inputs, :client

def treat_symbol_as_keyword?
client.config[:treat_symbol_as_keyword]
client.respond_to?(:config) && client.config[:treat_symbol_as_keyword]
end

def formatted(attributes, parent_keys: [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@
expect(call).to eq 'val: yes'
end
end

context 'when client does not respond to config' do
let(:client) { nil }

it 'converts Symbol values to strings' do
expect(call).to eq 'val: "yes"'
end
end

context 'when client has config as private method' do
let(:client_class) do
Class.new(ActiveGraphql::Client::Adapters::GraphlientAdapter) do
private :config
end
end

let(:client) { client_class.new(client_config) }

it 'converts Symbol values to strings' do
expect(call).to eq 'val: "yes"'
end
end
end

context 'when value is nested hash' do
Expand Down

0 comments on commit 83b5927

Please sign in to comment.