graphql 1.9.0.pre3 → 1.9.0.pre4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/lib/graphql/analysis/ast/visitor.rb +5 -0
  3. data/lib/graphql/execution/interpreter/hash_response.rb +1 -1
  4. data/lib/graphql/execution/interpreter/resolve.rb +2 -0
  5. data/lib/graphql/execution/interpreter/runtime.rb +11 -2
  6. data/lib/graphql/execution/lookahead.rb +1 -1
  7. data/lib/graphql/internal_representation/rewrite.rb +5 -5
  8. data/lib/graphql/language/parser.rb +1 -1
  9. data/lib/graphql/language/parser.y +1 -1
  10. data/lib/graphql/language/printer.rb +1 -1
  11. data/lib/graphql/language/visitor.rb +1 -1
  12. data/lib/graphql/query.rb +1 -1
  13. data/lib/graphql/query/arguments.rb +1 -1
  14. data/lib/graphql/query/arguments_cache.rb +1 -1
  15. data/lib/graphql/query/validation_pipeline.rb +3 -3
  16. data/lib/graphql/schema.rb +1 -1
  17. data/lib/graphql/schema/field.rb +25 -11
  18. data/lib/graphql/schema/field/connection_extension.rb +1 -1
  19. data/lib/graphql/schema/field_extension.rb +11 -3
  20. data/lib/graphql/schema/mutation.rb +1 -1
  21. data/lib/graphql/static_validation/base_visitor.rb +1 -1
  22. data/lib/graphql/static_validation/definition_dependencies.rb +3 -3
  23. data/lib/graphql/static_validation/literal_validator.rb +1 -1
  24. data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +1 -1
  25. data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +1 -1
  26. data/lib/graphql/static_validation/rules/fields_will_merge.rb +1 -1
  27. data/lib/graphql/static_validation/validator.rb +1 -1
  28. data/lib/graphql/types/relay/node_field.rb +15 -0
  29. data/lib/graphql/types/relay/nodes_field.rb +17 -1
  30. data/lib/graphql/version.rb +1 -1
  31. data/spec/graphql/analysis/ast_spec.rb +12 -0
  32. data/spec/graphql/execution/interpreter_spec.rb +83 -0
  33. data/spec/graphql/schema/field_extension_spec.rb +26 -4
  34. data/spec/graphql/static_validation/rules/argument_literals_are_compatible_spec.rb +3 -3
  35. data/spec/integration/rails/graphql/relay/mutation_spec.rb +48 -0
  36. data/spec/integration/tmp/app/graphql/types/family_type.rb +9 -0
  37. metadata +4 -98
  38. data/spec/integration/tmp/app/graphql/types/bird_type.rb +0 -7
  39. data/spec/integration/tmp/dummy/Gemfile +0 -45
  40. data/spec/integration/tmp/dummy/README.rdoc +0 -28
  41. data/spec/integration/tmp/dummy/Rakefile +0 -6
  42. data/spec/integration/tmp/dummy/app/assets/javascripts/application.js +0 -16
  43. data/spec/integration/tmp/dummy/app/assets/stylesheets/application.css +0 -15
  44. data/spec/integration/tmp/dummy/app/controllers/application_controller.rb +0 -5
  45. data/spec/integration/tmp/dummy/app/controllers/graphql_controller.rb +0 -43
  46. data/spec/integration/tmp/dummy/app/graphql/dummy_schema.rb +0 -34
  47. data/spec/integration/tmp/dummy/app/graphql/types/base_enum.rb +0 -4
  48. data/spec/integration/tmp/dummy/app/graphql/types/base_input_object.rb +0 -4
  49. data/spec/integration/tmp/dummy/app/graphql/types/base_interface.rb +0 -5
  50. data/spec/integration/tmp/dummy/app/graphql/types/base_object.rb +0 -4
  51. data/spec/integration/tmp/dummy/app/graphql/types/base_scalar.rb +0 -4
  52. data/spec/integration/tmp/dummy/app/graphql/types/base_union.rb +0 -4
  53. data/spec/integration/tmp/dummy/app/graphql/types/mutation_type.rb +0 -10
  54. data/spec/integration/tmp/dummy/app/graphql/types/query_type.rb +0 -15
  55. data/spec/integration/tmp/dummy/app/helpers/application_helper.rb +0 -2
  56. data/spec/integration/tmp/dummy/app/views/layouts/application.html.erb +0 -14
  57. data/spec/integration/tmp/dummy/bin/bundle +0 -3
  58. data/spec/integration/tmp/dummy/bin/rails +0 -4
  59. data/spec/integration/tmp/dummy/bin/rake +0 -4
  60. data/spec/integration/tmp/dummy/bin/setup +0 -29
  61. data/spec/integration/tmp/dummy/config.ru +0 -4
  62. data/spec/integration/tmp/dummy/config/application.rb +0 -32
  63. data/spec/integration/tmp/dummy/config/boot.rb +0 -3
  64. data/spec/integration/tmp/dummy/config/environment.rb +0 -5
  65. data/spec/integration/tmp/dummy/config/environments/development.rb +0 -38
  66. data/spec/integration/tmp/dummy/config/environments/production.rb +0 -76
  67. data/spec/integration/tmp/dummy/config/environments/test.rb +0 -42
  68. data/spec/integration/tmp/dummy/config/initializers/assets.rb +0 -11
  69. data/spec/integration/tmp/dummy/config/initializers/backtrace_silencers.rb +0 -7
  70. data/spec/integration/tmp/dummy/config/initializers/cookies_serializer.rb +0 -3
  71. data/spec/integration/tmp/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  72. data/spec/integration/tmp/dummy/config/initializers/inflections.rb +0 -16
  73. data/spec/integration/tmp/dummy/config/initializers/mime_types.rb +0 -4
  74. data/spec/integration/tmp/dummy/config/initializers/session_store.rb +0 -3
  75. data/spec/integration/tmp/dummy/config/initializers/to_time_preserves_timezone.rb +0 -10
  76. data/spec/integration/tmp/dummy/config/initializers/wrap_parameters.rb +0 -9
  77. data/spec/integration/tmp/dummy/config/locales/en.yml +0 -23
  78. data/spec/integration/tmp/dummy/config/routes.rb +0 -61
  79. data/spec/integration/tmp/dummy/config/secrets.yml +0 -22
  80. data/spec/integration/tmp/dummy/db/seeds.rb +0 -7
  81. data/spec/integration/tmp/dummy/public/404.html +0 -67
  82. data/spec/integration/tmp/dummy/public/422.html +0 -67
  83. data/spec/integration/tmp/dummy/public/500.html +0 -66
  84. data/spec/integration/tmp/dummy/public/favicon.ico +0 -0
  85. data/spec/integration/tmp/dummy/public/robots.txt +0 -5
@@ -1,7 +0,0 @@
1
- module Types
2
- module BirdType
3
- include Types::BaseInterface
4
- field :wingspan, Integer, null: false
5
- field :foliage, [Types::ColorType], null: true
6
- end
7
- end
@@ -1,45 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
-
4
- # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
5
- gem 'rails', '4.2.10'
6
- # Use SCSS for stylesheets
7
- gem 'sass-rails', '~> 5.0'
8
- # Use Uglifier as compressor for JavaScript assets
9
- gem 'uglifier', '>= 1.3.0'
10
- # Use CoffeeScript for .coffee assets and views
11
- gem 'coffee-rails', '~> 4.1.0'
12
- # See https://github.com/rails/execjs#readme for more supported runtimes
13
- # gem 'therubyracer', platforms: :ruby
14
-
15
- # Use jquery as the JavaScript library
16
- gem 'jquery-rails'
17
- # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
18
- gem 'turbolinks'
19
- # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
20
- gem 'jbuilder', '~> 2.0'
21
- # bundle exec rake doc:rails generates the API under doc/api.
22
- gem 'sdoc', '~> 0.4.0', group: :doc
23
-
24
- # Use ActiveModel has_secure_password
25
- # gem 'bcrypt', '~> 3.1.7'
26
-
27
- # Use Unicorn as the app server
28
- # gem 'unicorn'
29
-
30
- # Use Capistrano for deployment
31
- # gem 'capistrano-rails', group: :development
32
-
33
- group :development, :test do
34
- # Call 'byebug' anywhere in the code to stop execution and get a debugger console
35
- gem 'byebug'
36
- end
37
-
38
- group :development do
39
- # Access an IRB console on exception pages or by using <%= console %> in views
40
- gem 'web-console', '~> 2.0'
41
- end
42
-
43
-
44
- gem 'graphql-batch'
45
- gem 'graphiql-rails', group: :development
@@ -1,28 +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
- * ...
25
-
26
-
27
- Please feel free to use a different markup language if you do not plan to run
28
- <tt>rake doc:app</tt>.
@@ -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 File.expand_path('../config/application', __FILE__)
5
-
6
- Rails.application.load_tasks
@@ -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.
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,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 styles
10
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
- * file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
@@ -1,5 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- # Prevent CSRF attacks by raising an exception.
3
- # For APIs, you may want to use :null_session instead.
4
- protect_from_forgery with: :exception
5
- end
@@ -1,43 +0,0 @@
1
- class GraphqlController < ApplicationController
2
- def execute
3
- variables = ensure_hash(params[:variables])
4
- query = params[:query]
5
- operation_name = params[:operationName]
6
- context = {
7
- # Query context goes here, for example:
8
- # current_user: current_user,
9
- }
10
- result = DummySchema.execute(query, variables: variables, context: context, operation_name: operation_name)
11
- render json: result
12
- rescue => e
13
- raise e unless Rails.env.development?
14
- handle_error_in_development e
15
- end
16
-
17
- private
18
-
19
- # Handle form data, JSON body, or a blank value
20
- def ensure_hash(ambiguous_param)
21
- case ambiguous_param
22
- when String
23
- if ambiguous_param.present?
24
- ensure_hash(JSON.parse(ambiguous_param))
25
- else
26
- {}
27
- end
28
- when Hash, ActionController::Parameters
29
- ambiguous_param
30
- when nil
31
- {}
32
- else
33
- raise ArgumentError, "Unexpected parameter: #{ambiguous_param}"
34
- end
35
- end
36
-
37
- def handle_error_in_development(e)
38
- logger.error e.message
39
- logger.error e.backtrace.join("\n")
40
-
41
- render json: { error: { message: e.message, backtrace: e.backtrace }, data: {} }, status: 500
42
- end
43
- end
@@ -1,34 +0,0 @@
1
- class DummySchema < GraphQL::Schema
2
-
3
- mutation(Types::MutationType)
4
- query(Types::QueryType)
5
- # Relay Object Identification:
6
-
7
- # Return a string UUID for `object`
8
- def self.id_from_object(object, type_definition, query_ctx)
9
- # Here's a simple implementation which:
10
- # - joins the type name & object.id
11
- # - encodes it with base64:
12
- # GraphQL::Schema::UniqueWithinType.encode(type_definition.name, object.id)
13
- end
14
-
15
- # Given a string UUID, find the object
16
- def self.object_from_id(id, query_ctx)
17
- # For example, to decode the UUIDs generated above:
18
- # type_name, item_id = GraphQL::Schema::UniqueWithinType.decode(id)
19
- #
20
- # Then, based on `type_name` and `id`
21
- # find an object in your application
22
- # ...
23
- end
24
-
25
- # Object Resolution
26
- def self.resolve_type(type, obj, ctx)
27
- # TODO: Implement this function
28
- # to return the correct type for `obj`
29
- raise(NotImplementedError)
30
- end
31
-
32
- # GraphQL::Batch setup:
33
- use GraphQL::Batch
34
- end
@@ -1,4 +0,0 @@
1
- module Types
2
- class BaseEnum < GraphQL::Schema::Enum
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Types
2
- class BaseInputObject < GraphQL::Schema::InputObject
3
- end
4
- end
@@ -1,5 +0,0 @@
1
- module Types
2
- module BaseInterface
3
- include GraphQL::Schema::Interface
4
- end
5
- end
@@ -1,4 +0,0 @@
1
- module Types
2
- class BaseObject < GraphQL::Schema::Object
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Types
2
- class BaseScalar < GraphQL::Schema::Scalar
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module Types
2
- class BaseUnion < GraphQL::Schema::Union
3
- end
4
- end
@@ -1,10 +0,0 @@
1
- module Types
2
- class MutationType < Types::BaseObject
3
- # TODO: remove me
4
- field :test_field, String, null: false,
5
- description: "An example field added by the generator"
6
- def test_field
7
- "Hello World"
8
- end
9
- end
10
- end
@@ -1,15 +0,0 @@
1
- module Types
2
- class QueryType < Types::BaseObject
3
- # Add root-level fields here.
4
- # They will be entry points for queries on your schema.
5
-
6
- # TODO: remove me
7
- field :test_field, String, null: false,
8
- description: "An example field added by the generator"
9
- def test_field
10
- "Hello World!"
11
- end
12
-
13
- field :node, field: GraphQL::Relay::Node.field
14
- end
15
- end
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
- <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </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', __FILE__)
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,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'pathname'
3
-
4
- # path to your application root.
5
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
-
7
- Dir.chdir APP_ROOT do
8
- # This script is a starting point to setup your application.
9
- # Add necessary setup steps to this file:
10
-
11
- puts "== Installing dependencies =="
12
- system "gem install bundler --conservative"
13
- system "bundle check || bundle install"
14
-
15
- # puts "\n== Copying sample files =="
16
- # unless File.exist?("config/database.yml")
17
- # system "cp config/database.yml.sample config/database.yml"
18
- # end
19
-
20
- puts "\n== Preparing database =="
21
- system "bin/rake db:setup"
22
-
23
- puts "\n== Removing old logs and tempfiles =="
24
- system "rm -f log/*"
25
- system "rm -rf tmp/cache"
26
-
27
- puts "\n== Restarting application server =="
28
- system "touch tmp/restart.txt"
29
- end
@@ -1,4 +0,0 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require ::File.expand_path('../config/environment', __FILE__)
4
- run Rails.application
@@ -1,32 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require "rails"
4
- # Pick the frameworks you want:
5
- require "active_model/railtie"
6
- require "active_job/railtie"
7
- # require "active_record/railtie"
8
- require "action_controller/railtie"
9
- require "action_mailer/railtie"
10
- require "action_view/railtie"
11
- require "sprockets/railtie"
12
- # require "rails/test_unit/railtie"
13
-
14
- # Require the gems listed in Gemfile, including any gems
15
- # you've limited to :test, :development, or :production.
16
- Bundler.require(*Rails.groups)
17
-
18
- module Dummy
19
- class Application < Rails::Application
20
- # Settings in config/environments/* take precedence over those specified here.
21
- # Application configuration should go into files in config/initializers
22
- # -- all .rb files in that directory are automatically loaded.
23
-
24
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
25
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
26
- # config.time_zone = 'Central Time (US & Canada)'
27
-
28
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
29
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
30
- # config.i18n.default_locale = :de
31
- end
32
- end
@@ -1,3 +0,0 @@
1
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2
-
3
- require 'bundler/setup' # Set up gems listed in the Gemfile.
@@ -1,5 +0,0 @@
1
- # Load the Rails application.
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the Rails application.
5
- Rails.application.initialize!
@@ -1,38 +0,0 @@
1
- Rails.application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb.
3
-
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
6
- # since you don't have to restart the web server when you make code changes.
7
- config.cache_classes = false
8
-
9
- # Do not eager load code on boot.
10
- config.eager_load = false
11
-
12
- # Show full error reports and disable caching.
13
- config.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
15
-
16
- # Don't care if the mailer can't send.
17
- config.action_mailer.raise_delivery_errors = false
18
-
19
- # Print deprecation notices to the Rails logger.
20
- config.active_support.deprecation = :log
21
-
22
- # Debug mode disables concatenation and preprocessing of assets.
23
- # This option may cause significant delays in view rendering with a large
24
- # number of complex assets.
25
- config.assets.debug = true
26
-
27
- # Asset digests allow you to set far-future HTTP expiration dates on all assets,
28
- # yet still be able to expire them through the digest params.
29
- config.assets.digest = true
30
-
31
- # Adds additional error checking when serving assets at runtime.
32
- # Checks for improperly declared sprockets dependencies.
33
- # Raises helpful error messages.
34
- config.assets.raise_runtime_errors = true
35
-
36
- # Raises error for missing translations
37
- # config.action_view.raise_on_missing_translations = true
38
- end