graphlient 0.8.0 → 0.9.0

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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +38 -38
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -20
  4. data/.github/workflows/ci.yml +33 -30
  5. data/.github/workflows/danger-comment.yml +10 -0
  6. data/.github/workflows/danger.yml +13 -22
  7. data/.github/workflows/rubocop.yml +19 -19
  8. data/.gitignore +59 -52
  9. data/.rspec +1 -1
  10. data/.rubocop.yml +26 -28
  11. data/.rubocop_todo.yml +72 -48
  12. data/CHANGELOG.md +128 -113
  13. data/CONTRIBUTING.md +125 -125
  14. data/Dangerfile +24 -24
  15. data/Gemfile +35 -27
  16. data/LICENSE +21 -21
  17. data/README.md +800 -533
  18. data/RELEASING.md +63 -63
  19. data/Rakefile +15 -15
  20. data/UPGRADING.md +23 -23
  21. data/graphlient.gemspec +19 -19
  22. data/lib/graphlient/adapters/http/adapter.rb +41 -41
  23. data/lib/graphlient/adapters/http/faraday_adapter.rb +79 -79
  24. data/lib/graphlient/adapters/http/http_adapter.rb +40 -39
  25. data/lib/graphlient/adapters/http.rb +3 -3
  26. data/lib/graphlient/adapters.rb +1 -1
  27. data/lib/graphlient/client.rb +98 -80
  28. data/lib/graphlient/errors/client_error.rb +6 -6
  29. data/lib/graphlient/errors/connection_failed_error.rb +6 -6
  30. data/lib/graphlient/errors/error.rb +13 -12
  31. data/lib/graphlient/errors/execution_error.rb +29 -29
  32. data/lib/graphlient/errors/faraday_server_error.rb +12 -12
  33. data/lib/graphlient/errors/graphql_error.rb +53 -52
  34. data/lib/graphlient/errors/http_options_error.rb +6 -6
  35. data/lib/graphlient/errors/http_server_error.rb +13 -13
  36. data/lib/graphlient/errors/server_error.rb +7 -7
  37. data/lib/graphlient/errors/timeout_error.rb +6 -6
  38. data/lib/graphlient/errors.rb +10 -10
  39. data/lib/graphlient/extensions/query.rb +15 -15
  40. data/lib/graphlient/extensions.rb +1 -1
  41. data/lib/graphlient/query/directive.rb +47 -0
  42. data/lib/graphlient/query/serializer/arguments.rb +67 -0
  43. data/lib/graphlient/query/serializer/directives.rb +17 -0
  44. data/lib/graphlient/query/serializer/evaluator.rb +15 -0
  45. data/lib/graphlient/query/serializer/fragments.rb +28 -0
  46. data/lib/graphlient/query/serializer/scalars.rb +63 -0
  47. data/lib/graphlient/query/serializer.rb +153 -0
  48. data/lib/graphlient/query.rb +29 -128
  49. data/lib/graphlient/schema.rb +27 -26
  50. data/lib/graphlient/version.rb +3 -3
  51. data/lib/graphlient.rb +8 -8
  52. data/spec/graphlient/adapters/http/faraday_adapter_spec.rb +172 -167
  53. data/spec/graphlient/adapters/http/http_adapter_spec.rb +60 -60
  54. data/spec/graphlient/client_dsl_spec.rb +153 -0
  55. data/spec/graphlient/client_query_spec.rb +369 -346
  56. data/spec/graphlient/client_schema_spec.rb +75 -75
  57. data/spec/graphlient/extensions/query_spec.rb +16 -16
  58. data/spec/graphlient/github_query_spec.rb +32 -32
  59. data/spec/graphlient/query_dsl_spec.rb +231 -0
  60. data/spec/graphlient/query_spec.rb +105 -105
  61. data/spec/graphlient/schema_spec.rb +56 -56
  62. data/spec/graphlient/static_client_query_spec.rb +75 -68
  63. data/spec/graphlient/webmock_client_query_spec.rb +41 -41
  64. data/spec/spec_helper.rb +26 -14
  65. data/spec/support/context/dummy_client.rb +33 -26
  66. data/spec/support/context/github_client.rb +18 -18
  67. data/spec/support/dummy_app.rb +21 -19
  68. data/spec/support/dummy_schema.rb +17 -17
  69. data/spec/support/fixtures/github/schema.yml +14282 -14282
  70. data/spec/support/fixtures/github/user.yml +76 -76
  71. data/spec/support/fixtures/github/viewer.yml +76 -76
  72. data/spec/support/fixtures/invoice_api.json +1288 -1288
  73. data/spec/support/mutations/create_invoice.rb +18 -18
  74. data/spec/support/queries/query.rb +48 -47
  75. data/spec/support/schema/github.json +44479 -44479
  76. data/spec/support/types/invoice_type.rb +13 -13
  77. data/spec/support/types/mutation_type.rb +5 -5
  78. data/spec/support/vcr.rb +9 -9
  79. metadata +13 -8
  80. data/Gemfile.danger +0 -5
@@ -1,18 +1,18 @@
1
- RSpec.shared_context 'Github Client', shared_context: :metadata do
2
- let(:endpoint) { 'https://api.github.com/graphql' }
3
-
4
- let(:headers) do
5
- {
6
- 'Authorization' => "Bearer #{ENV['GITHUB_ACCESS_TOKEN']}",
7
- 'Content-Type' => 'application/json'
8
- }
9
- end
10
-
11
- let(:client) do
12
- Graphlient::Client.new(
13
- endpoint,
14
- headers: headers,
15
- schema_path: File.expand_path("#{__dir__}/../schema/github.json")
16
- )
17
- end
18
- end
1
+ RSpec.shared_context 'Github Client', shared_context: :metadata do
2
+ let(:endpoint) { 'https://api.github.com/graphql' }
3
+
4
+ let(:headers) do
5
+ {
6
+ 'Authorization' => "Bearer #{ENV['GITHUB_ACCESS_TOKEN']}",
7
+ 'Content-Type' => 'application/json'
8
+ }
9
+ end
10
+
11
+ let(:client) do
12
+ Graphlient::Client.new(
13
+ endpoint,
14
+ headers: headers,
15
+ schema_path: File.expand_path("#{__dir__}/../schema/github.json")
16
+ )
17
+ end
18
+ end
@@ -1,19 +1,21 @@
1
- require 'sinatra'
2
- require 'rack/parser'
3
- require_relative './dummy_schema'
4
-
5
- use Rack::Parser
6
-
7
- before do
8
- halt! 403 unless request.env['HTTP_AUTHORIZATION'] == 'Bearer 1231'
9
- end
10
-
11
- post '/graphql' do
12
- headers['Content-Type'] = 'application/json'
13
- DummySchema.execute(
14
- params[:query],
15
- variables: params[:variables] || {},
16
- context: {},
17
- operation_name: params[:operationName]
18
- ).to_json
19
- end
1
+ require 'sinatra'
2
+ require 'rack/parser'
3
+ require_relative './dummy_schema'
4
+
5
+ set :environment, :test
6
+
7
+ use Rack::Parser
8
+
9
+ before do
10
+ halt 403 unless request.env['HTTP_AUTHORIZATION'] == 'Bearer 1231'
11
+ end
12
+
13
+ post '/graphql' do
14
+ headers['Content-Type'] = 'application/json'
15
+ DummySchema.execute(
16
+ params[:query],
17
+ variables: params[:variables] || {},
18
+ context: {},
19
+ operation_name: params[:operationName]
20
+ ).to_json
21
+ end
@@ -1,17 +1,17 @@
1
- require_relative 'types/invoice_type'
2
-
3
- require_relative 'queries/query'
4
- require_relative 'types/mutation_type.rb'
5
-
6
- require 'graphql/errors'
7
-
8
- class DummySchema < GraphQL::Schema
9
- query(Query)
10
- mutation(MutationType)
11
- end
12
-
13
- GraphQL::Errors.configure(DummySchema) do
14
- rescue_from StandardError do |e|
15
- GraphQL::ExecutionError.new(e.message)
16
- end
17
- end
1
+ require_relative 'types/invoice_type'
2
+
3
+ require_relative 'queries/query'
4
+ require_relative 'types/mutation_type'
5
+
6
+ require 'graphql/errors'
7
+
8
+ class DummySchema < GraphQL::Schema
9
+ query(Query)
10
+ mutation(MutationType)
11
+ end
12
+
13
+ GraphQL::Errors.configure(DummySchema) do
14
+ rescue_from StandardError do |e|
15
+ GraphQL::ExecutionError.new(e.message)
16
+ end
17
+ end