graphql 1.9.7 → 1.9.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/graphql/install_generator.rb +2 -1
  3. data/lib/generators/graphql/templates/base_argument.erb +4 -0
  4. data/lib/generators/graphql/templates/base_field.erb +2 -0
  5. data/lib/generators/graphql/templates/base_input_object.erb +1 -0
  6. data/lib/graphql/analysis/ast/query_complexity.rb +34 -18
  7. data/lib/graphql/argument.rb +8 -2
  8. data/lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb +1 -1
  9. data/lib/graphql/language/lexer.rb +24 -13
  10. data/lib/graphql/language/lexer.rl +23 -13
  11. data/lib/graphql/query/arguments.rb +16 -15
  12. data/lib/graphql/schema.rb +105 -48
  13. data/lib/graphql/schema/argument.rb +12 -1
  14. data/lib/graphql/schema/build_from_definition.rb +3 -0
  15. data/lib/graphql/schema/field.rb +3 -8
  16. data/lib/graphql/schema/find_inherited_value.rb +20 -0
  17. data/lib/graphql/schema/input_object.rb +1 -3
  18. data/lib/graphql/schema/loader.rb +1 -0
  19. data/lib/graphql/schema/member/base_dsl_methods.rb +7 -18
  20. data/lib/graphql/schema/member/has_arguments.rb +4 -9
  21. data/lib/graphql/schema/member/has_fields.rb +14 -0
  22. data/lib/graphql/schema/member/relay_shortcuts.rb +2 -2
  23. data/lib/graphql/schema/resolver.rb +31 -8
  24. data/lib/graphql/schema/resolver/has_payload_type.rb +3 -2
  25. data/lib/graphql/schema/subscription.rb +1 -1
  26. data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +1 -1
  27. data/lib/graphql/version.rb +1 -1
  28. data/spec/graphql/analysis/analyze_query_spec.rb +14 -25
  29. data/spec/graphql/analysis/ast/max_query_complexity_spec.rb +7 -19
  30. data/spec/graphql/analysis/ast/max_query_depth_spec.rb +5 -12
  31. data/spec/graphql/analysis/max_query_complexity_spec.rb +12 -20
  32. data/spec/graphql/analysis/max_query_depth_spec.rb +6 -13
  33. data/spec/graphql/language/lexer_spec.rb +19 -1
  34. data/spec/graphql/schema/argument_spec.rb +1 -1
  35. data/spec/graphql/schema/build_from_definition_spec.rb +10 -0
  36. data/spec/graphql/schema/catchall_middleware_spec.rb +6 -9
  37. data/spec/graphql/schema/input_object_spec.rb +25 -0
  38. data/spec/graphql/schema/loader_spec.rb +65 -1
  39. data/spec/graphql/schema/object_spec.rb +21 -0
  40. data/spec/graphql/schema/resolver_spec.rb +30 -1
  41. data/spec/graphql/schema_spec.rb +135 -0
  42. data/spec/graphql/static_validation/rules/required_arguments_are_present_spec.rb +25 -0
  43. data/spec/integration/rails/generators/graphql/install_generator_spec.rb +20 -0
  44. data/spec/integration/tmp/app/graphql/types/page_type.rb +5 -0
  45. data/spec/support/dummy/schema.rb +1 -1
  46. data/spec/support/lazy_helpers.rb +1 -1
  47. data/spec/support/parser/filename_example_invalid_utf8.graphql +1 -0
  48. metadata +10 -132
  49. data/spec/integration/tmp/app/graphql/types/date_type.rb +0 -14
  50. data/spec/integration/tmp/dummy/Gemfile +0 -50
  51. data/spec/integration/tmp/dummy/README.md +0 -24
  52. data/spec/integration/tmp/dummy/Rakefile +0 -6
  53. data/spec/integration/tmp/dummy/app/assets/config/manifest.js +0 -3
  54. data/spec/integration/tmp/dummy/app/assets/javascripts/application.js +0 -16
  55. data/spec/integration/tmp/dummy/app/assets/javascripts/cable.js +0 -13
  56. data/spec/integration/tmp/dummy/app/assets/stylesheets/application.css +0 -15
  57. data/spec/integration/tmp/dummy/app/channels/application_cable/channel.rb +0 -5
  58. data/spec/integration/tmp/dummy/app/channels/application_cable/connection.rb +0 -5
  59. data/spec/integration/tmp/dummy/app/controllers/application_controller.rb +0 -4
  60. data/spec/integration/tmp/dummy/app/controllers/graphql_controller.rb +0 -44
  61. data/spec/integration/tmp/dummy/app/helpers/application_helper.rb +0 -3
  62. data/spec/integration/tmp/dummy/app/jobs/application_job.rb +0 -3
  63. data/spec/integration/tmp/dummy/app/mailers/application_mailer.rb +0 -5
  64. data/spec/integration/tmp/dummy/app/mydirectory/dummy_schema.rb +0 -5
  65. data/spec/integration/tmp/dummy/app/mydirectory/mutations/update_name.rb +0 -15
  66. data/spec/integration/tmp/dummy/app/mydirectory/types/base_enum.rb +0 -5
  67. data/spec/integration/tmp/dummy/app/mydirectory/types/base_input_object.rb +0 -5
  68. data/spec/integration/tmp/dummy/app/mydirectory/types/base_interface.rb +0 -6
  69. data/spec/integration/tmp/dummy/app/mydirectory/types/base_object.rb +0 -5
  70. data/spec/integration/tmp/dummy/app/mydirectory/types/base_scalar.rb +0 -5
  71. data/spec/integration/tmp/dummy/app/mydirectory/types/base_union.rb +0 -5
  72. data/spec/integration/tmp/dummy/app/mydirectory/types/mutation_type.rb +0 -12
  73. data/spec/integration/tmp/dummy/app/mydirectory/types/query_type.rb +0 -14
  74. data/spec/integration/tmp/dummy/app/views/layouts/application.html.erb +0 -14
  75. data/spec/integration/tmp/dummy/app/views/layouts/mailer.html.erb +0 -13
  76. data/spec/integration/tmp/dummy/app/views/layouts/mailer.text.erb +0 -1
  77. data/spec/integration/tmp/dummy/bin/bundle +0 -3
  78. data/spec/integration/tmp/dummy/bin/rails +0 -4
  79. data/spec/integration/tmp/dummy/bin/rake +0 -4
  80. data/spec/integration/tmp/dummy/bin/setup +0 -34
  81. data/spec/integration/tmp/dummy/bin/update +0 -29
  82. data/spec/integration/tmp/dummy/config.ru +0 -5
  83. data/spec/integration/tmp/dummy/config/application.rb +0 -26
  84. data/spec/integration/tmp/dummy/config/boot.rb +0 -4
  85. data/spec/integration/tmp/dummy/config/cable.yml +0 -9
  86. data/spec/integration/tmp/dummy/config/environment.rb +0 -6
  87. data/spec/integration/tmp/dummy/config/environments/development.rb +0 -52
  88. data/spec/integration/tmp/dummy/config/environments/production.rb +0 -84
  89. data/spec/integration/tmp/dummy/config/environments/test.rb +0 -43
  90. data/spec/integration/tmp/dummy/config/initializers/application_controller_renderer.rb +0 -9
  91. data/spec/integration/tmp/dummy/config/initializers/assets.rb +0 -12
  92. data/spec/integration/tmp/dummy/config/initializers/backtrace_silencers.rb +0 -8
  93. data/spec/integration/tmp/dummy/config/initializers/cookies_serializer.rb +0 -6
  94. data/spec/integration/tmp/dummy/config/initializers/filter_parameter_logging.rb +0 -5
  95. data/spec/integration/tmp/dummy/config/initializers/inflections.rb +0 -17
  96. data/spec/integration/tmp/dummy/config/initializers/mime_types.rb +0 -5
  97. data/spec/integration/tmp/dummy/config/initializers/new_framework_defaults.rb +0 -24
  98. data/spec/integration/tmp/dummy/config/initializers/session_store.rb +0 -4
  99. data/spec/integration/tmp/dummy/config/initializers/wrap_parameters.rb +0 -10
  100. data/spec/integration/tmp/dummy/config/locales/en.yml +0 -23
  101. data/spec/integration/tmp/dummy/config/puma.rb +0 -48
  102. data/spec/integration/tmp/dummy/config/routes.rb +0 -9
  103. data/spec/integration/tmp/dummy/config/secrets.yml +0 -22
  104. data/spec/integration/tmp/dummy/db/seeds.rb +0 -8
  105. data/spec/integration/tmp/dummy/log/test.log +0 -0
  106. data/spec/integration/tmp/dummy/public/404.html +0 -67
  107. data/spec/integration/tmp/dummy/public/422.html +0 -67
  108. data/spec/integration/tmp/dummy/public/500.html +0 -66
  109. data/spec/integration/tmp/dummy/public/apple-touch-icon-precomposed.png +0 -0
  110. data/spec/integration/tmp/dummy/public/apple-touch-icon.png +0 -0
  111. data/spec/integration/tmp/dummy/public/favicon.ico +0 -0
  112. data/spec/integration/tmp/dummy/public/robots.txt +0 -5
  113. data/spec/integration/tmp/dummy/test/test_helper.rb +0 -8
@@ -1,14 +0,0 @@
1
- # typed: true
2
- module Types
3
- class DateType < Types::BaseScalar
4
- def self.coerce_input(input_value, context)
5
- # Override this to prepare a client-provided GraphQL value for your Ruby code
6
- input_value
7
- end
8
-
9
- def self.coerce_result(ruby_value, context)
10
- # Override this to serialize a Ruby value for the GraphQL response
11
- ruby_value.to_s
12
- end
13
- end
14
- end
@@ -1,50 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- git_source(:github) do |repo_name|
4
- repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
5
- "https://github.com/#{repo_name}.git"
6
- end
7
-
8
-
9
- # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
10
- gem 'rails', '~> 5.0.7', '>= 5.0.7.2'
11
- # Use Puma as the app server
12
- gem 'puma', '~> 3.0'
13
- # Use SCSS for stylesheets
14
- gem 'sass-rails', '~> 5.0'
15
- # Use Uglifier as compressor for JavaScript assets
16
- gem 'uglifier', '>= 1.3.0'
17
- # Use CoffeeScript for .coffee assets and views
18
- gem 'coffee-rails', '~> 4.2'
19
- # See https://github.com/rails/execjs#readme for more supported runtimes
20
- # gem 'therubyracer', platforms: :ruby
21
-
22
- # Use jquery as the JavaScript library
23
- gem 'jquery-rails'
24
- # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
25
- gem 'turbolinks', '~> 5'
26
- # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
27
- gem 'jbuilder', '~> 2.5'
28
- # Use Redis adapter to run Action Cable in production
29
- # gem 'redis', '~> 3.0'
30
- # Use ActiveModel has_secure_password
31
- # gem 'bcrypt', '~> 3.1.7'
32
-
33
- # Use Capistrano for deployment
34
- # gem 'capistrano-rails', group: :development
35
-
36
- group :development, :test do
37
- # Call 'byebug' anywhere in the code to stop execution and get a debugger console
38
- gem 'byebug', platform: :mri
39
- end
40
-
41
- group :development do
42
- # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
43
- gem 'web-console', '>= 3.3.0'
44
- gem 'listen', '~> 3.0.5'
45
- end
46
-
47
- # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
48
- gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
49
-
50
- gem 'graphiql-rails', group: :development
@@ -1,24 +0,0 @@
1
- # README
2
-
3
- This README would normally document whatever steps are necessary to get the
4
- application up and running.
5
-
6
- Things you may want to cover:
7
-
8
- * Ruby version
9
-
10
- * System dependencies
11
-
12
- * Configuration
13
-
14
- * Database creation
15
-
16
- * Database initialization
17
-
18
- * How to run the test suite
19
-
20
- * Services (job queues, cache servers, search engines, etc.)
21
-
22
- * Deployment instructions
23
-
24
- * ...
@@ -1,6 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require_relative 'config/application'
5
-
6
- Rails.application.load_tasks
@@ -1,3 +0,0 @@
1
- //= link_tree ../images
2
- //= link_directory ../javascripts .js
3
- //= link_directory ../stylesheets .css
@@ -1,16 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
- //
10
- // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require jquery
14
- //= require jquery_ujs
15
- //= require turbolinks
16
- //= require_tree .
@@ -1,13 +0,0 @@
1
- // Action Cable provides the framework to deal with WebSockets in Rails.
2
- // You can generate new channels where WebSocket features live using the rails generate channel command.
3
- //
4
- //= require action_cable
5
- //= require_self
6
- //= require_tree ./channels
7
-
8
- (function() {
9
- this.App || (this.App = {});
10
-
11
- App.cable = ActionCable.createConsumer();
12
-
13
- }).call(this);
@@ -1,15 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
- * files in this directory. Styles in this file should be added after the last require_* statement.
11
- * It is generally better to create a new file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
@@ -1,5 +0,0 @@
1
- # typed: strong
2
- module ApplicationCable
3
- class Channel < ActionCable::Channel::Base
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- # typed: strong
2
- module ApplicationCable
3
- class Connection < ActionCable::Connection::Base
4
- end
5
- end
@@ -1,4 +0,0 @@
1
- # typed: false
2
- class ApplicationController < ActionController::Base
3
- protect_from_forgery with: :exception
4
- end
@@ -1,44 +0,0 @@
1
- # typed: false
2
- class GraphqlController < ApplicationController
3
- def execute
4
- variables = ensure_hash(params[:variables])
5
- query = params[:query]
6
- operation_name = params[:operationName]
7
- context = {
8
- # Query context goes here, for example:
9
- # current_user: current_user,
10
- }
11
- result = DummySchema.execute(query, variables: variables, context: context, operation_name: operation_name)
12
- render json: result
13
- rescue => e
14
- raise e unless Rails.env.development?
15
- handle_error_in_development e
16
- end
17
-
18
- private
19
-
20
- # Handle form data, JSON body, or a blank value
21
- def ensure_hash(ambiguous_param)
22
- case ambiguous_param
23
- when String
24
- if ambiguous_param.present?
25
- ensure_hash(JSON.parse(ambiguous_param))
26
- else
27
- {}
28
- end
29
- when Hash, ActionController::Parameters
30
- ambiguous_param
31
- when nil
32
- {}
33
- else
34
- raise ArgumentError, "Unexpected parameter: #{ambiguous_param}"
35
- end
36
- end
37
-
38
- def handle_error_in_development(e)
39
- logger.error e.message
40
- logger.error e.backtrace.join("\n")
41
-
42
- render json: { error: { message: e.message, backtrace: e.backtrace }, data: {} }, status: 500
43
- end
44
- end
@@ -1,3 +0,0 @@
1
- # typed: strong
2
- module ApplicationHelper
3
- end
@@ -1,3 +0,0 @@
1
- # typed: strong
2
- class ApplicationJob < ActiveJob::Base
3
- end
@@ -1,5 +0,0 @@
1
- # typed: false
2
- class ApplicationMailer < ActionMailer::Base
3
- default from: 'from@example.com'
4
- layout 'mailer'
5
- end
@@ -1,5 +0,0 @@
1
- # typed: strict
2
- class DummySchema < GraphQL::Schema
3
- mutation(Types::MutationType)
4
- query(Types::QueryType)
5
- end
@@ -1,15 +0,0 @@
1
- # typed: strong
2
- module Mutations
3
- class UpdateName < GraphQL::Schema::RelayClassicMutation
4
- # TODO: define return fields
5
- # field :post, Types::PostType, null: false
6
-
7
- # TODO: define arguments
8
- # argument :name, String, required: true
9
-
10
- # TODO: define resolve method
11
- # def resolve(name:)
12
- # { post: ... }
13
- # end
14
- end
15
- end
@@ -1,5 +0,0 @@
1
- # typed: strong
2
- module Types
3
- class BaseEnum < GraphQL::Schema::Enum
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- # typed: strong
2
- module Types
3
- class BaseInputObject < GraphQL::Schema::InputObject
4
- end
5
- end
@@ -1,6 +0,0 @@
1
- # typed: strong
2
- module Types
3
- module BaseInterface
4
- include GraphQL::Schema::Interface
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- # typed: strong
2
- module Types
3
- class BaseObject < GraphQL::Schema::Object
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- # typed: strong
2
- module Types
3
- class BaseScalar < GraphQL::Schema::Scalar
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- # typed: strong
2
- module Types
3
- class BaseUnion < GraphQL::Schema::Union
4
- end
5
- end
@@ -1,12 +0,0 @@
1
- # typed: strict
2
- module Types
3
- class MutationType < Types::BaseObject
4
- field :updateName, mutation: Mutations::UpdateName
5
- # TODO: remove me
6
- field :test_field, String, null: false,
7
- description: "An example field added by the generator"
8
- def test_field
9
- "Hello World"
10
- end
11
- end
12
- end
@@ -1,14 +0,0 @@
1
- # typed: strict
2
- module Types
3
- class QueryType < Types::BaseObject
4
- # Add root-level fields here.
5
- # They will be entry points for queries on your schema.
6
-
7
- # TODO: remove me
8
- field :test_field, String, null: false,
9
- description: "An example field added by the generator"
10
- def test_field
11
- "Hello World!"
12
- end
13
- end
14
- end
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= csrf_meta_tags %>
6
-
7
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
8
- <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
9
- </head>
10
-
11
- <body>
12
- <%= yield %>
13
- </body>
14
- </html>
@@ -1,13 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
- <style>
6
- /* Email styles need to be inline */
7
- </style>
8
- </head>
9
-
10
- <body>
11
- <%= yield %>
12
- </body>
13
- </html>
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
- load Gem.bin_path('bundler', 'bundle')
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../config/application', __dir__)
3
- require_relative '../config/boot'
4
- require 'rails/commands'
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require_relative '../config/boot'
3
- require 'rake'
4
- Rake.application.run
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'pathname'
3
- require 'fileutils'
4
- include FileUtils
5
-
6
- # path to your application root.
7
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
-
9
- def system!(*args)
10
- system(*args) || abort("\n== Command #{args} failed ==")
11
- end
12
-
13
- chdir APP_ROOT do
14
- # This script is a starting point to setup your application.
15
- # Add necessary setup steps to this file.
16
-
17
- puts '== Installing dependencies =='
18
- system! 'gem install bundler --conservative'
19
- system('bundle check') || system!('bundle install')
20
-
21
- # puts "\n== Copying sample files =="
22
- # unless File.exist?('config/database.yml')
23
- # cp 'config/database.yml.sample', 'config/database.yml'
24
- # end
25
-
26
- puts "\n== Preparing database =="
27
- system! 'bin/rails db:setup'
28
-
29
- puts "\n== Removing old logs and tempfiles =="
30
- system! 'bin/rails log:clear tmp:clear'
31
-
32
- puts "\n== Restarting application server =="
33
- system! 'bin/rails restart'
34
- end
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'pathname'
3
- require 'fileutils'
4
- include FileUtils
5
-
6
- # path to your application root.
7
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
-
9
- def system!(*args)
10
- system(*args) || abort("\n== Command #{args} failed ==")
11
- end
12
-
13
- chdir APP_ROOT do
14
- # This script is a way to update your development environment automatically.
15
- # Add necessary update steps to this file.
16
-
17
- puts '== Installing dependencies =='
18
- system! 'gem install bundler --conservative'
19
- system('bundle check') || system!('bundle install')
20
-
21
- puts "\n== Updating database =="
22
- system! 'bin/rails db:migrate'
23
-
24
- puts "\n== Removing old logs and tempfiles =="
25
- system! 'bin/rails log:clear tmp:clear'
26
-
27
- puts "\n== Restarting application server =="
28
- system! 'bin/rails restart'
29
- end