graphql 1.9.6 → 1.9.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +5 -5
  2. data/lib/generators/graphql/install_generator.rb +2 -1
  3. data/lib/generators/graphql/templates/base_field.erb +7 -0
  4. data/lib/graphql/analysis/ast/visitor.rb +5 -2
  5. data/lib/graphql/execution/multiplex.rb +5 -1
  6. data/lib/graphql/query.rb +6 -1
  7. data/lib/graphql/relay/array_connection.rb +1 -1
  8. data/lib/graphql/schema.rb +15 -1
  9. data/lib/graphql/schema/argument.rb +5 -1
  10. data/lib/graphql/schema/input_object.rb +21 -12
  11. data/lib/graphql/schema/introspection_system.rb +6 -1
  12. data/lib/graphql/schema/member/has_arguments.rb +4 -2
  13. data/lib/graphql/schema/resolver.rb +8 -3
  14. data/lib/graphql/schema/subscription.rb +22 -0
  15. data/lib/graphql/schema/timeout.rb +109 -0
  16. data/lib/graphql/types/relay/base_edge.rb +0 -3
  17. data/lib/graphql/upgrader/member.rb +148 -111
  18. data/lib/graphql/version.rb +1 -1
  19. data/readme.md +1 -1
  20. data/spec/fixtures/upgrader/mutation.original.rb +28 -0
  21. data/spec/fixtures/upgrader/mutation.transformed.rb +28 -0
  22. data/spec/graphql/analysis/ast_spec.rb +27 -0
  23. data/spec/graphql/execution/instrumentation_spec.rb +34 -6
  24. data/spec/graphql/execution/multiplex_spec.rb +11 -0
  25. data/spec/graphql/internal_representation/rewrite_spec.rb +6 -1
  26. data/spec/graphql/schema/input_object_spec.rb +56 -7
  27. data/spec/graphql/schema/introspection_system_spec.rb +24 -0
  28. data/spec/graphql/schema/subscription_spec.rb +65 -0
  29. data/spec/graphql/schema/timeout_spec.rb +206 -0
  30. data/spec/integration/mongoid/star_trek/schema.rb +1 -2
  31. data/spec/integration/rails/graphql/input_object_spec.rb +19 -0
  32. data/spec/integration/rails/graphql/relay/array_connection_spec.rb +47 -28
  33. data/spec/integration/rails/graphql/schema_spec.rb +18 -0
  34. data/spec/integration/tmp/app/graphql/types/date_type.rb +14 -0
  35. data/spec/integration/tmp/dummy/Gemfile +50 -0
  36. data/spec/integration/tmp/dummy/README.md +24 -0
  37. data/spec/integration/tmp/dummy/Rakefile +6 -0
  38. data/spec/integration/tmp/dummy/app/assets/config/manifest.js +3 -0
  39. data/spec/integration/tmp/dummy/app/assets/javascripts/application.js +16 -0
  40. data/spec/integration/tmp/dummy/app/assets/javascripts/cable.js +13 -0
  41. data/spec/integration/tmp/dummy/app/assets/stylesheets/application.css +15 -0
  42. data/spec/integration/tmp/dummy/app/channels/application_cable/channel.rb +5 -0
  43. data/spec/integration/tmp/dummy/app/channels/application_cable/connection.rb +5 -0
  44. data/spec/integration/tmp/dummy/app/controllers/application_controller.rb +4 -0
  45. data/spec/integration/tmp/dummy/app/controllers/graphql_controller.rb +44 -0
  46. data/spec/integration/tmp/dummy/app/helpers/application_helper.rb +3 -0
  47. data/spec/integration/tmp/dummy/app/jobs/application_job.rb +3 -0
  48. data/spec/integration/tmp/dummy/app/mailers/application_mailer.rb +5 -0
  49. data/spec/integration/tmp/dummy/app/mydirectory/dummy_schema.rb +5 -0
  50. data/spec/integration/tmp/dummy/app/mydirectory/mutations/update_name.rb +15 -0
  51. data/spec/integration/tmp/dummy/app/mydirectory/types/base_enum.rb +5 -0
  52. data/spec/integration/tmp/dummy/app/mydirectory/types/base_input_object.rb +5 -0
  53. data/spec/integration/tmp/dummy/app/mydirectory/types/base_interface.rb +6 -0
  54. data/spec/integration/tmp/dummy/app/mydirectory/types/base_object.rb +5 -0
  55. data/spec/integration/tmp/dummy/app/mydirectory/types/base_scalar.rb +5 -0
  56. data/spec/integration/tmp/dummy/app/mydirectory/types/base_union.rb +5 -0
  57. data/spec/integration/tmp/dummy/app/mydirectory/types/mutation_type.rb +12 -0
  58. data/spec/integration/tmp/dummy/app/mydirectory/types/query_type.rb +14 -0
  59. data/spec/integration/tmp/dummy/app/views/layouts/application.html.erb +14 -0
  60. data/spec/integration/tmp/dummy/app/views/layouts/mailer.html.erb +13 -0
  61. data/spec/integration/tmp/dummy/app/views/layouts/mailer.text.erb +1 -0
  62. data/spec/integration/tmp/dummy/bin/bundle +3 -0
  63. data/spec/integration/tmp/dummy/bin/rails +4 -0
  64. data/spec/integration/tmp/dummy/bin/rake +4 -0
  65. data/spec/integration/tmp/dummy/bin/setup +34 -0
  66. data/spec/integration/tmp/dummy/bin/update +29 -0
  67. data/spec/integration/tmp/dummy/config.ru +5 -0
  68. data/spec/integration/tmp/dummy/config/application.rb +26 -0
  69. data/spec/integration/tmp/dummy/config/boot.rb +4 -0
  70. data/spec/integration/tmp/dummy/config/cable.yml +9 -0
  71. data/spec/integration/tmp/dummy/config/environment.rb +6 -0
  72. data/spec/integration/tmp/dummy/config/environments/development.rb +52 -0
  73. data/spec/integration/tmp/dummy/config/environments/production.rb +84 -0
  74. data/spec/integration/tmp/dummy/config/environments/test.rb +43 -0
  75. data/spec/integration/tmp/dummy/config/initializers/application_controller_renderer.rb +9 -0
  76. data/spec/integration/tmp/dummy/config/initializers/assets.rb +12 -0
  77. data/spec/integration/tmp/dummy/config/initializers/backtrace_silencers.rb +8 -0
  78. data/spec/integration/tmp/dummy/config/initializers/cookies_serializer.rb +6 -0
  79. data/spec/integration/tmp/dummy/config/initializers/filter_parameter_logging.rb +5 -0
  80. data/spec/integration/tmp/dummy/config/initializers/inflections.rb +17 -0
  81. data/spec/integration/tmp/dummy/config/initializers/mime_types.rb +5 -0
  82. data/spec/integration/tmp/dummy/config/initializers/new_framework_defaults.rb +24 -0
  83. data/spec/integration/tmp/dummy/config/initializers/session_store.rb +4 -0
  84. data/spec/integration/tmp/dummy/config/initializers/wrap_parameters.rb +10 -0
  85. data/spec/integration/tmp/dummy/config/locales/en.yml +23 -0
  86. data/spec/integration/tmp/dummy/config/puma.rb +48 -0
  87. data/spec/integration/tmp/dummy/config/routes.rb +9 -0
  88. data/spec/integration/tmp/dummy/config/secrets.yml +22 -0
  89. data/spec/integration/tmp/dummy/db/seeds.rb +8 -0
  90. data/spec/integration/tmp/dummy/log/test.log +0 -0
  91. data/spec/integration/tmp/dummy/public/404.html +67 -0
  92. data/spec/integration/tmp/dummy/public/422.html +67 -0
  93. data/spec/integration/tmp/dummy/public/500.html +66 -0
  94. data/spec/integration/tmp/dummy/public/apple-touch-icon-precomposed.png +0 -0
  95. data/spec/integration/tmp/dummy/public/apple-touch-icon.png +0 -0
  96. data/spec/integration/tmp/dummy/public/favicon.ico +0 -0
  97. data/spec/integration/tmp/dummy/public/robots.txt +5 -0
  98. data/spec/integration/tmp/dummy/test/test_helper.rb +8 -0
  99. data/spec/support/jazz.rb +6 -0
  100. data/spec/support/star_wars/schema.rb +1 -2
  101. metadata +171 -6
  102. data/spec/integration/tmp/app/graphql/types/bird_type.rb +0 -7
@@ -0,0 +1,5 @@
1
+ # typed: strong
2
+ module Types
3
+ class BaseScalar < GraphQL::Schema::Scalar
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ # typed: strong
2
+ module Types
3
+ class BaseUnion < GraphQL::Schema::Union
4
+ end
5
+ end
@@ -0,0 +1,12 @@
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
@@ -0,0 +1,14 @@
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
@@ -0,0 +1,14 @@
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>
@@ -0,0 +1,13 @@
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>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,34 @@
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
@@ -0,0 +1,29 @@
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
@@ -0,0 +1,5 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require_relative 'config/environment'
4
+
5
+ run Rails.application
@@ -0,0 +1,26 @@
1
+ # typed: false
2
+ require_relative 'boot'
3
+
4
+ require "rails"
5
+ # Pick the frameworks you want:
6
+ require "active_model/railtie"
7
+ require "active_job/railtie"
8
+ # require "active_record/railtie"
9
+ require "action_controller/railtie"
10
+ require "action_mailer/railtie"
11
+ require "action_view/railtie"
12
+ require "action_cable/engine"
13
+ require "sprockets/railtie"
14
+ require "rails/test_unit/railtie"
15
+
16
+ # Require the gems listed in Gemfile, including any gems
17
+ # you've limited to :test, :development, or :production.
18
+ Bundler.require(*Rails.groups)
19
+
20
+ module Dummy
21
+ class Application < Rails::Application
22
+ # Settings in config/environments/* take precedence over those specified here.
23
+ # Application configuration should go into files in config/initializers
24
+ # -- all .rb files in that directory are automatically loaded.
25
+ end
26
+ end
@@ -0,0 +1,4 @@
1
+ # typed: strong
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3
+
4
+ require 'bundler/setup' # Set up gems listed in the Gemfile.
@@ -0,0 +1,9 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: async
6
+
7
+ production:
8
+ adapter: redis
9
+ url: redis://localhost:6379/1
@@ -0,0 +1,6 @@
1
+ # typed: false
2
+ # Load the Rails application.
3
+ require_relative 'application'
4
+
5
+ # Initialize the Rails application.
6
+ Rails.application.initialize!
@@ -0,0 +1,52 @@
1
+ # typed: false
2
+ Rails.application.configure do
3
+ # Settings specified here will take precedence over those in config/application.rb.
4
+
5
+ # In the development environment your application's code is reloaded on
6
+ # every request. This slows down response time but is perfect for development
7
+ # since you don't have to restart the web server when you make code changes.
8
+ config.cache_classes = false
9
+
10
+ # Do not eager load code on boot.
11
+ config.eager_load = false
12
+
13
+ # Show full error reports.
14
+ config.consider_all_requests_local = true
15
+
16
+ # Enable/disable caching. By default caching is disabled.
17
+ if Rails.root.join('tmp/caching-dev.txt').exist?
18
+ config.action_controller.perform_caching = true
19
+
20
+ config.cache_store = :memory_store
21
+ config.public_file_server.headers = {
22
+ 'Cache-Control' => 'public, max-age=172800'
23
+ }
24
+ else
25
+ config.action_controller.perform_caching = false
26
+
27
+ config.cache_store = :null_store
28
+ end
29
+
30
+ # Don't care if the mailer can't send.
31
+ config.action_mailer.raise_delivery_errors = false
32
+
33
+ config.action_mailer.perform_caching = false
34
+
35
+ # Print deprecation notices to the Rails logger.
36
+ config.active_support.deprecation = :log
37
+
38
+ # Debug mode disables concatenation and preprocessing of assets.
39
+ # This option may cause significant delays in view rendering with a large
40
+ # number of complex assets.
41
+ config.assets.debug = true
42
+
43
+ # Suppress logger output for asset requests.
44
+ config.assets.quiet = true
45
+
46
+ # Raises error for missing translations
47
+ # config.action_view.raise_on_missing_translations = true
48
+
49
+ # Use an evented file watcher to asynchronously detect changes in source code,
50
+ # routes, locales, etc. This feature depends on the listen gem.
51
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
52
+ end
@@ -0,0 +1,84 @@
1
+ # typed: false
2
+ Rails.application.configure do
3
+ # Settings specified here will take precedence over those in config/application.rb.
4
+
5
+ # Code is not reloaded between requests.
6
+ config.cache_classes = true
7
+
8
+ # Eager load code on boot. This eager loads most of Rails and
9
+ # your application in memory, allowing both threaded web servers
10
+ # and those relying on copy on write to perform better.
11
+ # Rake tasks automatically ignore this option for performance.
12
+ config.eager_load = true
13
+
14
+ # Full error reports are disabled and caching is turned on.
15
+ config.consider_all_requests_local = false
16
+ config.action_controller.perform_caching = true
17
+
18
+ # Disable serving static files from the `/public` folder by default since
19
+ # Apache or NGINX already handles this.
20
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
21
+
22
+ # Compress JavaScripts and CSS.
23
+ config.assets.js_compressor = :uglifier
24
+ # config.assets.css_compressor = :sass
25
+
26
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
27
+ config.assets.compile = false
28
+
29
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
30
+
31
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
32
+ # config.action_controller.asset_host = 'http://assets.example.com'
33
+
34
+ # Specifies the header that your server uses for sending files.
35
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
36
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
37
+
38
+ # Mount Action Cable outside main process or domain
39
+ # config.action_cable.mount_path = nil
40
+ # config.action_cable.url = 'wss://example.com/cable'
41
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
42
+
43
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
44
+ # config.force_ssl = true
45
+
46
+ # Use the lowest log level to ensure availability of diagnostic information
47
+ # when problems arise.
48
+ config.log_level = :debug
49
+
50
+ # Prepend all log lines with the following tags.
51
+ config.log_tags = [ :request_id ]
52
+
53
+ # Use a different cache store in production.
54
+ # config.cache_store = :mem_cache_store
55
+
56
+ # Use a real queuing backend for Active Job (and separate queues per environment)
57
+ # config.active_job.queue_adapter = :resque
58
+ # config.active_job.queue_name_prefix = "dummy_#{Rails.env}"
59
+ config.action_mailer.perform_caching = false
60
+
61
+ # Ignore bad email addresses and do not raise email delivery errors.
62
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
63
+ # config.action_mailer.raise_delivery_errors = false
64
+
65
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
66
+ # the I18n.default_locale when a translation cannot be found).
67
+ config.i18n.fallbacks = true
68
+
69
+ # Send deprecation notices to registered listeners.
70
+ config.active_support.deprecation = :notify
71
+
72
+ # Use default logging formatter so that PID and timestamp are not suppressed.
73
+ config.log_formatter = ::Logger::Formatter.new
74
+
75
+ # Use a different logger for distributed setups.
76
+ # require 'syslog/logger'
77
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
78
+
79
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
80
+ logger = ActiveSupport::Logger.new(STDOUT)
81
+ logger.formatter = config.log_formatter
82
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
83
+ end
84
+ end
@@ -0,0 +1,43 @@
1
+ # typed: false
2
+ Rails.application.configure do
3
+ # Settings specified here will take precedence over those in config/application.rb.
4
+
5
+ # The test environment is used exclusively to run your application's
6
+ # test suite. You never need to work with it otherwise. Remember that
7
+ # your test database is "scratch space" for the test suite and is wiped
8
+ # and recreated between test runs. Don't rely on the data there!
9
+ config.cache_classes = true
10
+
11
+ # Do not eager load code on boot. This avoids loading your whole application
12
+ # just for the purpose of running a single test. If you are using a tool that
13
+ # preloads Rails for running tests, you may have to set it to true.
14
+ config.eager_load = false
15
+
16
+ # Configure public file server for tests with Cache-Control for performance.
17
+ config.public_file_server.enabled = true
18
+ config.public_file_server.headers = {
19
+ 'Cache-Control' => 'public, max-age=3600'
20
+ }
21
+
22
+ # Show full error reports and disable caching.
23
+ config.consider_all_requests_local = true
24
+ config.action_controller.perform_caching = false
25
+
26
+ # Raise exceptions instead of rendering exception templates.
27
+ config.action_dispatch.show_exceptions = false
28
+
29
+ # Disable request forgery protection in test environment.
30
+ config.action_controller.allow_forgery_protection = false
31
+ config.action_mailer.perform_caching = false
32
+
33
+ # Tell Action Mailer not to deliver emails to the real world.
34
+ # The :test delivery method accumulates sent emails in the
35
+ # ActionMailer::Base.deliveries array.
36
+ config.action_mailer.delivery_method = :test
37
+
38
+ # Print deprecation notices to the stderr.
39
+ config.active_support.deprecation = :stderr
40
+
41
+ # Raises error for missing translations
42
+ # config.action_view.raise_on_missing_translations = true
43
+ end
@@ -0,0 +1,9 @@
1
+ # typed: strong
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # ActiveSupport::Reloader.to_prepare do
5
+ # ApplicationController.renderer.defaults.merge!(
6
+ # http_host: 'example.org',
7
+ # https: false
8
+ # )
9
+ # end
@@ -0,0 +1,12 @@
1
+ # typed: false
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # Version of your assets, change this if you want to expire all your assets.
5
+ Rails.application.config.assets.version = '1.0'
6
+
7
+ # Add additional assets to the asset load path
8
+ # Rails.application.config.assets.paths << Emoji.images_path
9
+
10
+ # Precompile additional assets.
11
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
12
+ # Rails.application.config.assets.precompile += %w( search.js )
@@ -0,0 +1,8 @@
1
+ # typed: strong
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
5
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
6
+
7
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
8
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,6 @@
1
+ # typed: false
2
+ # Be sure to restart your server when you modify this file.
3
+
4
+ # Specify a serializer for the signed and encrypted cookie jars.
5
+ # Valid options are :json, :marshal, and :hybrid.
6
+ Rails.application.config.action_dispatch.cookies_serializer = :json