diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 38eeee8..218ce6b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -48,3 +48,8 @@ Style/MultilineBlockChain: Exclude: - 'spec/graphlient/client_query_spec.rb' - 'spec/graphlient/client_schema_spec.rb' + +Style/SafeNavigation: + Exclude: + - 'lib/graphlient/client.rb' + - 'lib/graphlient/adapters/http/http_adapter.rb' diff --git a/.travis.yml b/.travis.yml index 86eea83..d57861e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: ruby cache: bundler rvm: + - 2.2.9 - 2.3.6 - 2.4.3 - 2.5.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 0397608..a33af42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ * Your contribution here. * [#38](https://github.com/ashkan18/graphlient/pull/38): Add support for Ruby 2.5 - [@yuki24](https://github.com/yuki24). +* [#39](https://github.com/ashkan18/graphlient/pull/39): Add support for Ruby 2.2 - [@yuki24](https://github.com/yuki24). ### 0.2.0 (11/09/2017) diff --git a/lib/graphlient/adapters/http/http_adapter.rb b/lib/graphlient/adapters/http/http_adapter.rb index eb3125a..a5e9daa 100644 --- a/lib/graphlient/adapters/http/http_adapter.rb +++ b/lib/graphlient/adapters/http/http_adapter.rb @@ -9,7 +9,7 @@ def execute(document:, operation_name: nil, variables: {}, context: {}) request['Accept'] = 'application/json' request['Content-Type'] = 'application/json' - headers&.each { |name, value| request[name] = value } + headers && headers.each { |name, value| request[name] = value } body = {} body['query'] = document.to_query_string diff --git a/lib/graphlient/client.rb b/lib/graphlient/client.rb index d4b2ad8..de7d45d 100644 --- a/lib/graphlient/client.rb +++ b/lib/graphlient/client.rb @@ -26,7 +26,7 @@ def execute(query, variables = nil) raise Graphlient::Errors::GraphQLError, rc if rc.errors.any? # see https://github.com/github/graphql-client/pull/132 # see https://github.com/exAspArk/graphql-errors/issues/2 - raise Graphlient::Errors::ExecutionError, rc if rc.data&.errors && rc.data.errors.any? + raise Graphlient::Errors::ExecutionError, rc if rc.data && rc.data.errors && rc.data.errors.any? rc rescue GraphQL::Client::Error => e raise Graphlient::Errors::ClientError.new(e.message, e) diff --git a/spec/graphlient/client_query_spec.rb b/spec/graphlient/client_query_spec.rb index 54831e0..0ad0c2c 100644 --- a/spec/graphlient/client_query_spec.rb +++ b/spec/graphlient/client_query_spec.rb @@ -128,7 +128,7 @@ end it 'returns a response from a GRAPHQL query' do - response = client.query <<~GRAPHQL + response = client.query <<-GRAPHQL query { invoices(ids: [10]) { id