graphql 1.9.7 → 1.9.8
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.
- checksums.yaml +4 -4
- data/lib/generators/graphql/install_generator.rb +2 -1
- data/lib/generators/graphql/templates/base_argument.erb +4 -0
- data/lib/generators/graphql/templates/base_field.erb +2 -0
- data/lib/generators/graphql/templates/base_input_object.erb +1 -0
- data/lib/graphql/analysis/ast/query_complexity.rb +34 -18
- data/lib/graphql/argument.rb +8 -2
- data/lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb +1 -1
- data/lib/graphql/language/lexer.rb +24 -13
- data/lib/graphql/language/lexer.rl +23 -13
- data/lib/graphql/query/arguments.rb +16 -15
- data/lib/graphql/schema.rb +105 -48
- data/lib/graphql/schema/argument.rb +12 -1
- data/lib/graphql/schema/build_from_definition.rb +3 -0
- data/lib/graphql/schema/field.rb +3 -8
- data/lib/graphql/schema/find_inherited_value.rb +20 -0
- data/lib/graphql/schema/input_object.rb +1 -3
- data/lib/graphql/schema/loader.rb +1 -0
- data/lib/graphql/schema/member/base_dsl_methods.rb +7 -18
- data/lib/graphql/schema/member/has_arguments.rb +4 -9
- data/lib/graphql/schema/member/has_fields.rb +14 -0
- data/lib/graphql/schema/member/relay_shortcuts.rb +2 -2
- data/lib/graphql/schema/resolver.rb +31 -8
- data/lib/graphql/schema/resolver/has_payload_type.rb +3 -2
- data/lib/graphql/schema/subscription.rb +1 -1
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +1 -1
- data/lib/graphql/version.rb +1 -1
- data/spec/graphql/analysis/analyze_query_spec.rb +14 -25
- data/spec/graphql/analysis/ast/max_query_complexity_spec.rb +7 -19
- data/spec/graphql/analysis/ast/max_query_depth_spec.rb +5 -12
- data/spec/graphql/analysis/max_query_complexity_spec.rb +12 -20
- data/spec/graphql/analysis/max_query_depth_spec.rb +6 -13
- data/spec/graphql/language/lexer_spec.rb +19 -1
- data/spec/graphql/schema/argument_spec.rb +1 -1
- data/spec/graphql/schema/build_from_definition_spec.rb +10 -0
- data/spec/graphql/schema/catchall_middleware_spec.rb +6 -9
- data/spec/graphql/schema/input_object_spec.rb +25 -0
- data/spec/graphql/schema/loader_spec.rb +65 -1
- data/spec/graphql/schema/object_spec.rb +21 -0
- data/spec/graphql/schema/resolver_spec.rb +30 -1
- data/spec/graphql/schema_spec.rb +135 -0
- data/spec/graphql/static_validation/rules/required_arguments_are_present_spec.rb +25 -0
- data/spec/integration/rails/generators/graphql/install_generator_spec.rb +20 -0
- data/spec/integration/tmp/app/graphql/types/page_type.rb +5 -0
- data/spec/support/dummy/schema.rb +1 -1
- data/spec/support/lazy_helpers.rb +1 -1
- data/spec/support/parser/filename_example_invalid_utf8.graphql +1 -0
- metadata +10 -132
- data/spec/integration/tmp/app/graphql/types/date_type.rb +0 -14
- data/spec/integration/tmp/dummy/Gemfile +0 -50
- data/spec/integration/tmp/dummy/README.md +0 -24
- data/spec/integration/tmp/dummy/Rakefile +0 -6
- data/spec/integration/tmp/dummy/app/assets/config/manifest.js +0 -3
- data/spec/integration/tmp/dummy/app/assets/javascripts/application.js +0 -16
- data/spec/integration/tmp/dummy/app/assets/javascripts/cable.js +0 -13
- data/spec/integration/tmp/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/integration/tmp/dummy/app/channels/application_cable/channel.rb +0 -5
- data/spec/integration/tmp/dummy/app/channels/application_cable/connection.rb +0 -5
- data/spec/integration/tmp/dummy/app/controllers/application_controller.rb +0 -4
- data/spec/integration/tmp/dummy/app/controllers/graphql_controller.rb +0 -44
- data/spec/integration/tmp/dummy/app/helpers/application_helper.rb +0 -3
- data/spec/integration/tmp/dummy/app/jobs/application_job.rb +0 -3
- data/spec/integration/tmp/dummy/app/mailers/application_mailer.rb +0 -5
- data/spec/integration/tmp/dummy/app/mydirectory/dummy_schema.rb +0 -5
- data/spec/integration/tmp/dummy/app/mydirectory/mutations/update_name.rb +0 -15
- data/spec/integration/tmp/dummy/app/mydirectory/types/base_enum.rb +0 -5
- data/spec/integration/tmp/dummy/app/mydirectory/types/base_input_object.rb +0 -5
- data/spec/integration/tmp/dummy/app/mydirectory/types/base_interface.rb +0 -6
- data/spec/integration/tmp/dummy/app/mydirectory/types/base_object.rb +0 -5
- data/spec/integration/tmp/dummy/app/mydirectory/types/base_scalar.rb +0 -5
- data/spec/integration/tmp/dummy/app/mydirectory/types/base_union.rb +0 -5
- data/spec/integration/tmp/dummy/app/mydirectory/types/mutation_type.rb +0 -12
- data/spec/integration/tmp/dummy/app/mydirectory/types/query_type.rb +0 -14
- data/spec/integration/tmp/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/integration/tmp/dummy/app/views/layouts/mailer.html.erb +0 -13
- data/spec/integration/tmp/dummy/app/views/layouts/mailer.text.erb +0 -1
- data/spec/integration/tmp/dummy/bin/bundle +0 -3
- data/spec/integration/tmp/dummy/bin/rails +0 -4
- data/spec/integration/tmp/dummy/bin/rake +0 -4
- data/spec/integration/tmp/dummy/bin/setup +0 -34
- data/spec/integration/tmp/dummy/bin/update +0 -29
- data/spec/integration/tmp/dummy/config.ru +0 -5
- data/spec/integration/tmp/dummy/config/application.rb +0 -26
- data/spec/integration/tmp/dummy/config/boot.rb +0 -4
- data/spec/integration/tmp/dummy/config/cable.yml +0 -9
- data/spec/integration/tmp/dummy/config/environment.rb +0 -6
- data/spec/integration/tmp/dummy/config/environments/development.rb +0 -52
- data/spec/integration/tmp/dummy/config/environments/production.rb +0 -84
- data/spec/integration/tmp/dummy/config/environments/test.rb +0 -43
- data/spec/integration/tmp/dummy/config/initializers/application_controller_renderer.rb +0 -9
- data/spec/integration/tmp/dummy/config/initializers/assets.rb +0 -12
- data/spec/integration/tmp/dummy/config/initializers/backtrace_silencers.rb +0 -8
- data/spec/integration/tmp/dummy/config/initializers/cookies_serializer.rb +0 -6
- data/spec/integration/tmp/dummy/config/initializers/filter_parameter_logging.rb +0 -5
- data/spec/integration/tmp/dummy/config/initializers/inflections.rb +0 -17
- data/spec/integration/tmp/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/integration/tmp/dummy/config/initializers/new_framework_defaults.rb +0 -24
- data/spec/integration/tmp/dummy/config/initializers/session_store.rb +0 -4
- data/spec/integration/tmp/dummy/config/initializers/wrap_parameters.rb +0 -10
- data/spec/integration/tmp/dummy/config/locales/en.yml +0 -23
- data/spec/integration/tmp/dummy/config/puma.rb +0 -48
- data/spec/integration/tmp/dummy/config/routes.rb +0 -9
- data/spec/integration/tmp/dummy/config/secrets.yml +0 -22
- data/spec/integration/tmp/dummy/db/seeds.rb +0 -8
- data/spec/integration/tmp/dummy/log/test.log +0 -0
- data/spec/integration/tmp/dummy/public/404.html +0 -67
- data/spec/integration/tmp/dummy/public/422.html +0 -67
- data/spec/integration/tmp/dummy/public/500.html +0 -66
- data/spec/integration/tmp/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/integration/tmp/dummy/public/apple-touch-icon.png +0 -0
- data/spec/integration/tmp/dummy/public/favicon.ico +0 -0
- data/spec/integration/tmp/dummy/public/robots.txt +0 -5
- 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,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,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,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,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 +0,0 @@
|
|
|
1
|
-
<%= yield %>
|
|
@@ -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
|