graphql-stitching 1.4.3 → 1.5.1
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/.gitignore +4 -0
- data/README.md +10 -7
- data/docs/README.md +1 -0
- data/docs/client.md +6 -0
- data/docs/composer.md +1 -1
- data/docs/subscriptions.md +208 -0
- data/docs/{resolver.md → type_resolver.md} +3 -3
- data/examples/subscriptions/.gitattributes +9 -0
- data/examples/subscriptions/.gitignore +35 -0
- data/examples/subscriptions/Gemfile +65 -0
- data/examples/subscriptions/README.md +38 -0
- data/examples/subscriptions/Rakefile +6 -0
- data/examples/subscriptions/app/channels/graphql_channel.rb +50 -0
- data/examples/subscriptions/app/controllers/graphql_controller.rb +44 -0
- data/examples/subscriptions/app/graphql/entities_schema.rb +42 -0
- data/examples/subscriptions/app/graphql/stitched_schema.rb +10 -0
- data/examples/subscriptions/app/graphql/subscriptions_schema.rb +54 -0
- data/examples/subscriptions/app/models/repository.rb +39 -0
- data/examples/subscriptions/app/views/graphql/client.html.erb +159 -0
- data/examples/subscriptions/bin/bundle +109 -0
- data/examples/subscriptions/bin/docker-entrypoint +8 -0
- data/examples/subscriptions/bin/importmap +4 -0
- data/examples/subscriptions/bin/rails +4 -0
- data/examples/subscriptions/bin/rake +4 -0
- data/examples/subscriptions/bin/setup +33 -0
- data/examples/subscriptions/config/application.rb +14 -0
- data/examples/subscriptions/config/boot.rb +4 -0
- data/examples/subscriptions/config/cable.yml +10 -0
- data/examples/subscriptions/config/credentials.yml.enc +1 -0
- data/examples/subscriptions/config/database.yml +25 -0
- data/examples/subscriptions/config/environment.rb +5 -0
- data/examples/subscriptions/config/environments/development.rb +74 -0
- data/examples/subscriptions/config/environments/production.rb +91 -0
- data/examples/subscriptions/config/environments/test.rb +64 -0
- data/examples/subscriptions/config/initializers/content_security_policy.rb +25 -0
- data/examples/subscriptions/config/initializers/filter_parameter_logging.rb +8 -0
- data/examples/subscriptions/config/initializers/inflections.rb +16 -0
- data/examples/subscriptions/config/initializers/permissions_policy.rb +13 -0
- data/examples/subscriptions/config/locales/en.yml +31 -0
- data/examples/subscriptions/config/master.key +1 -0
- data/examples/subscriptions/config/puma.rb +35 -0
- data/examples/subscriptions/config/routes.rb +8 -0
- data/examples/subscriptions/config/storage.yml +34 -0
- data/examples/subscriptions/config.ru +6 -0
- data/examples/subscriptions/db/seeds.rb +9 -0
- data/examples/subscriptions/public/404.html +17 -0
- data/examples/subscriptions/public/422.html +17 -0
- data/examples/subscriptions/public/500.html +16 -0
- data/examples/subscriptions/public/apple-touch-icon-precomposed.png +0 -0
- data/examples/subscriptions/public/apple-touch-icon.png +0 -0
- data/examples/subscriptions/public/favicon.ico +0 -0
- data/examples/subscriptions/public/robots.txt +1 -0
- data/lib/graphql/stitching/client.rb +18 -11
- data/lib/graphql/stitching/composer/{resolver_config.rb → type_resolver_config.rb} +3 -3
- data/lib/graphql/stitching/composer/{validate_resolvers.rb → validate_type_resolvers.rb} +8 -2
- data/lib/graphql/stitching/composer.rb +48 -42
- data/lib/graphql/stitching/executor/shaper.rb +3 -3
- data/lib/graphql/stitching/executor/{resolver_source.rb → type_resolver_source.rb} +2 -2
- data/lib/graphql/stitching/executor.rb +19 -11
- data/lib/graphql/stitching/http_executable.rb +3 -0
- data/lib/graphql/stitching/plan.rb +1 -1
- data/lib/graphql/stitching/planner/step.rb +1 -1
- data/lib/graphql/stitching/planner.rb +29 -15
- data/lib/graphql/stitching/{skip_include.rb → request/skip_include.rb} +3 -3
- data/lib/graphql/stitching/request.rb +44 -6
- data/lib/graphql/stitching/supergraph/to_definition.rb +3 -3
- data/lib/graphql/stitching/supergraph.rb +6 -3
- data/lib/graphql/stitching/{resolver → type_resolver}/arguments.rb +7 -7
- data/lib/graphql/stitching/{resolver → type_resolver}/keys.rb +3 -4
- data/lib/graphql/stitching/{resolver.rb → type_resolver.rb} +5 -5
- data/lib/graphql/stitching/util.rb +1 -0
- data/lib/graphql/stitching/version.rb +1 -1
- data/lib/graphql/stitching.rb +32 -4
- metadata +56 -10
@@ -0,0 +1,64 @@
|
|
1
|
+
require "active_support/core_ext/integer/time"
|
2
|
+
|
3
|
+
# The test environment is used exclusively to run your application's
|
4
|
+
# test suite. You never need to work with it otherwise. Remember that
|
5
|
+
# your test database is "scratch space" for the test suite and is wiped
|
6
|
+
# and recreated between test runs. Don't rely on the data there!
|
7
|
+
|
8
|
+
Rails.application.configure do
|
9
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
10
|
+
|
11
|
+
# While tests run files are not watched, reloading is not necessary.
|
12
|
+
config.enable_reloading = false
|
13
|
+
|
14
|
+
# Eager loading loads your entire application. When running a single test locally,
|
15
|
+
# this is usually not necessary, and can slow down your test suite. However, it's
|
16
|
+
# recommended that you enable it in continuous integration systems to ensure eager
|
17
|
+
# loading is working properly before deploying your code.
|
18
|
+
config.eager_load = ENV["CI"].present?
|
19
|
+
|
20
|
+
# Configure public file server for tests with Cache-Control for performance.
|
21
|
+
config.public_file_server.enabled = true
|
22
|
+
config.public_file_server.headers = {
|
23
|
+
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
|
24
|
+
}
|
25
|
+
|
26
|
+
# Show full error reports and disable caching.
|
27
|
+
config.consider_all_requests_local = true
|
28
|
+
config.action_controller.perform_caching = false
|
29
|
+
config.cache_store = :null_store
|
30
|
+
|
31
|
+
# Render exception templates for rescuable exceptions and raise for other exceptions.
|
32
|
+
config.action_dispatch.show_exceptions = :rescuable
|
33
|
+
|
34
|
+
# Disable request forgery protection in test environment.
|
35
|
+
config.action_controller.allow_forgery_protection = false
|
36
|
+
|
37
|
+
# Store uploaded files on the local file system in a temporary directory.
|
38
|
+
config.active_storage.service = :test
|
39
|
+
|
40
|
+
config.action_mailer.perform_caching = false
|
41
|
+
|
42
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
43
|
+
# The :test delivery method accumulates sent emails in the
|
44
|
+
# ActionMailer::Base.deliveries array.
|
45
|
+
config.action_mailer.delivery_method = :test
|
46
|
+
|
47
|
+
# Print deprecation notices to the stderr.
|
48
|
+
config.active_support.deprecation = :stderr
|
49
|
+
|
50
|
+
# Raise exceptions for disallowed deprecations.
|
51
|
+
config.active_support.disallowed_deprecation = :raise
|
52
|
+
|
53
|
+
# Tell Active Support which deprecation messages to disallow.
|
54
|
+
config.active_support.disallowed_deprecation_warnings = []
|
55
|
+
|
56
|
+
# Raises error for missing translations.
|
57
|
+
# config.i18n.raise_on_missing_translations = true
|
58
|
+
|
59
|
+
# Annotate rendered view with file names.
|
60
|
+
# config.action_view.annotate_rendered_view_with_filenames = true
|
61
|
+
|
62
|
+
# Raise error when a before_action's only/except options reference missing actions
|
63
|
+
config.action_controller.raise_on_missing_callback_actions = true
|
64
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Define an application-wide content security policy.
|
4
|
+
# See the Securing Rails Applications Guide for more information:
|
5
|
+
# https://guides.rubyonrails.org/security.html#content-security-policy-header
|
6
|
+
|
7
|
+
# Rails.application.configure do
|
8
|
+
# config.content_security_policy do |policy|
|
9
|
+
# policy.default_src :self, :https
|
10
|
+
# policy.font_src :self, :https, :data
|
11
|
+
# policy.img_src :self, :https, :data
|
12
|
+
# policy.object_src :none
|
13
|
+
# policy.script_src :self, :https
|
14
|
+
# policy.style_src :self, :https
|
15
|
+
# # Specify URI for violation reports
|
16
|
+
# # policy.report_uri "/csp-violation-report-endpoint"
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# # Generate session nonces for permitted importmap, inline scripts, and inline styles.
|
20
|
+
# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
|
21
|
+
# config.content_security_policy_nonce_directives = %w(script-src style-src)
|
22
|
+
#
|
23
|
+
# # Report violations without enforcing the policy.
|
24
|
+
# # config.content_security_policy_report_only = true
|
25
|
+
# end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
|
4
|
+
# Use this to limit dissemination of sensitive information.
|
5
|
+
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
|
6
|
+
Rails.application.config.filter_parameters += [
|
7
|
+
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
|
8
|
+
]
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format. Inflections
|
4
|
+
# are locale specific, and you may define rules for as many different
|
5
|
+
# locales as you wish. All of these examples are active by default:
|
6
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
7
|
+
# inflect.plural /^(ox)$/i, "\\1en"
|
8
|
+
# inflect.singular /^(ox)en/i, "\\1"
|
9
|
+
# inflect.irregular "person", "people"
|
10
|
+
# inflect.uncountable %w( fish sheep )
|
11
|
+
# end
|
12
|
+
|
13
|
+
# These inflection rules are supported but not enabled by default:
|
14
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
15
|
+
# inflect.acronym "RESTful"
|
16
|
+
# end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Define an application-wide HTTP permissions policy. For further
|
4
|
+
# information see: https://developers.google.com/web/updates/2018/06/feature-policy
|
5
|
+
|
6
|
+
# Rails.application.config.permissions_policy do |policy|
|
7
|
+
# policy.camera :none
|
8
|
+
# policy.gyroscope :none
|
9
|
+
# policy.microphone :none
|
10
|
+
# policy.usb :none
|
11
|
+
# policy.fullscreen :self
|
12
|
+
# policy.payment :self, "https://secure.example.com"
|
13
|
+
# end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Files in the config/locales directory are used for internationalization and
|
2
|
+
# are automatically loaded by Rails. If you want to use locales other than
|
3
|
+
# English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t "hello"
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t("hello") %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# To learn more about the API, please read the Rails Internationalization guide
|
20
|
+
# at https://guides.rubyonrails.org/i18n.html.
|
21
|
+
#
|
22
|
+
# Be aware that YAML interprets the following case-insensitive strings as
|
23
|
+
# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings
|
24
|
+
# must be quoted to be interpreted as strings. For example:
|
25
|
+
#
|
26
|
+
# en:
|
27
|
+
# "yes": yup
|
28
|
+
# enabled: "ON"
|
29
|
+
|
30
|
+
en:
|
31
|
+
hello: "Hello world"
|
@@ -0,0 +1 @@
|
|
1
|
+
b7cc7c63ca7597ff3f5fc4a6cb27b65d
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# This configuration file will be evaluated by Puma. The top-level methods that
|
2
|
+
# are invoked here are part of Puma's configuration DSL. For more information
|
3
|
+
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
|
4
|
+
|
5
|
+
# Puma can serve each request in a thread from an internal thread pool.
|
6
|
+
# The `threads` method setting takes two numbers: a minimum and maximum.
|
7
|
+
# Any libraries that use thread pools should be configured to match
|
8
|
+
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
9
|
+
# and maximum; this matches the default thread size of Active Record.
|
10
|
+
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
|
11
|
+
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
|
12
|
+
threads min_threads_count, max_threads_count
|
13
|
+
|
14
|
+
# Specifies that the worker count should equal the number of processors in production.
|
15
|
+
if ENV["RAILS_ENV"] == "production"
|
16
|
+
require "concurrent-ruby"
|
17
|
+
worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count })
|
18
|
+
workers worker_count if worker_count > 1
|
19
|
+
end
|
20
|
+
|
21
|
+
# Specifies the `worker_timeout` threshold that Puma will use to wait before
|
22
|
+
# terminating a worker in development environments.
|
23
|
+
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
|
24
|
+
|
25
|
+
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
26
|
+
port ENV.fetch("PORT") { 3000 }
|
27
|
+
|
28
|
+
# Specifies the `environment` that Puma will run in.
|
29
|
+
environment ENV.fetch("RAILS_ENV") { "development" }
|
30
|
+
|
31
|
+
# Specifies the `pidfile` that Puma will use.
|
32
|
+
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
|
33
|
+
|
34
|
+
# Allow puma to be restarted by `bin/rails restart` command.
|
35
|
+
plugin :tmp_restart
|
@@ -0,0 +1,34 @@
|
|
1
|
+
test:
|
2
|
+
service: Disk
|
3
|
+
root: <%= Rails.root.join("tmp/storage") %>
|
4
|
+
|
5
|
+
local:
|
6
|
+
service: Disk
|
7
|
+
root: <%= Rails.root.join("storage") %>
|
8
|
+
|
9
|
+
# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
|
10
|
+
# amazon:
|
11
|
+
# service: S3
|
12
|
+
# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
|
13
|
+
# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
|
14
|
+
# region: us-east-1
|
15
|
+
# bucket: your_own_bucket-<%= Rails.env %>
|
16
|
+
|
17
|
+
# Remember not to checkin your GCS keyfile to a repository
|
18
|
+
# google:
|
19
|
+
# service: GCS
|
20
|
+
# project: your_project
|
21
|
+
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
|
22
|
+
# bucket: your_own_bucket-<%= Rails.env %>
|
23
|
+
|
24
|
+
# Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
|
25
|
+
# microsoft:
|
26
|
+
# service: AzureStorage
|
27
|
+
# storage_account_name: your_account_name
|
28
|
+
# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
|
29
|
+
# container: your_container_name-<%= Rails.env %>
|
30
|
+
|
31
|
+
# mirror:
|
32
|
+
# service: Mirror
|
33
|
+
# primary: local
|
34
|
+
# mirrors: [ amazon, google, microsoft ]
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# This file should ensure the existence of records required to run the application in every environment (production,
|
2
|
+
# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
|
3
|
+
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
|
4
|
+
#
|
5
|
+
# Example:
|
6
|
+
#
|
7
|
+
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
|
8
|
+
# MovieGenre.find_or_create_by!(name: genre_name)
|
9
|
+
# end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
</head>
|
7
|
+
|
8
|
+
<body class="rails-default-error-page">
|
9
|
+
<div class="dialog">
|
10
|
+
<div>
|
11
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
12
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
13
|
+
</div>
|
14
|
+
<p>If you are the application owner check the logs for more information.</p>
|
15
|
+
</div>
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
</head>
|
7
|
+
|
8
|
+
<body class="rails-default-error-page">
|
9
|
+
<div class="dialog">
|
10
|
+
<div>
|
11
|
+
<h1>The change you wanted was rejected.</h1>
|
12
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
13
|
+
</div>
|
14
|
+
<p>If you are the application owner check the logs for more information.</p>
|
15
|
+
</div>
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
</head>
|
7
|
+
|
8
|
+
<body class="rails-default-error-page">
|
9
|
+
<div class="dialog">
|
10
|
+
<div>
|
11
|
+
<h1>We're sorry, but something went wrong.</h1>
|
12
|
+
</div>
|
13
|
+
<p>If you are the application owner check the logs for more information.</p>
|
14
|
+
</div>
|
15
|
+
</body>
|
16
|
+
</html>
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
|
@@ -4,20 +4,27 @@ require "json"
|
|
4
4
|
|
5
5
|
module GraphQL
|
6
6
|
module Stitching
|
7
|
+
# Client is an out-of-the-box helper that assembles all
|
8
|
+
# stitching components into a workflow that executes requests.
|
7
9
|
class Client
|
8
10
|
class ClientError < StitchingError; end
|
9
11
|
|
12
|
+
# @return [Supergraph] composed supergraph that services incoming requests.
|
10
13
|
attr_reader :supergraph
|
11
14
|
|
15
|
+
# Builds a new client instance. Either `supergraph` or `locations` configuration is required.
|
16
|
+
# @param supergraph [Supergraph] optional, a pre-composed supergraph that bypasses composer setup.
|
17
|
+
# @param locations [Hash<Symbol, Hash<Symbol, untyped>>] optional, composer configurations for each graph location.
|
18
|
+
# @param composer [Composer] optional, a pre-configured composer instance for use with `locations` configuration.
|
12
19
|
def initialize(locations: nil, supergraph: nil, composer: nil)
|
13
20
|
@supergraph = if locations && supergraph
|
14
21
|
raise ClientError, "Cannot provide both locations and a supergraph."
|
15
|
-
elsif supergraph && !supergraph.is_a?(
|
22
|
+
elsif supergraph && !supergraph.is_a?(Supergraph)
|
16
23
|
raise ClientError, "Provided supergraph must be a GraphQL::Stitching::Supergraph instance."
|
17
24
|
elsif supergraph
|
18
25
|
supergraph
|
19
26
|
else
|
20
|
-
composer ||=
|
27
|
+
composer ||= Composer.new
|
21
28
|
composer.perform(locations)
|
22
29
|
end
|
23
30
|
|
@@ -26,10 +33,10 @@ module GraphQL
|
|
26
33
|
@on_error = nil
|
27
34
|
end
|
28
35
|
|
29
|
-
def execute(query
|
30
|
-
request =
|
36
|
+
def execute(raw_query = nil, query: nil, variables: nil, operation_name: nil, context: nil, validate: true)
|
37
|
+
request = Request.new(
|
31
38
|
@supergraph,
|
32
|
-
query,
|
39
|
+
raw_query || query, # << for parity with GraphQL Ruby Schema.execute
|
33
40
|
operation_name: operation_name,
|
34
41
|
variables: variables,
|
35
42
|
context: context,
|
@@ -37,17 +44,17 @@ module GraphQL
|
|
37
44
|
|
38
45
|
if validate
|
39
46
|
validation_errors = request.validate
|
40
|
-
return error_result(validation_errors) if validation_errors.any?
|
47
|
+
return error_result(request, validation_errors) if validation_errors.any?
|
41
48
|
end
|
42
49
|
|
43
50
|
request.prepare!
|
44
51
|
load_plan(request)
|
45
52
|
request.execute
|
46
53
|
rescue GraphQL::ParseError, GraphQL::ExecutionError => e
|
47
|
-
error_result([e])
|
54
|
+
error_result(request, [e])
|
48
55
|
rescue StandardError => e
|
49
56
|
custom_message = @on_error.call(request, e) if @on_error
|
50
|
-
error_result([{ "message" => custom_message || "An unexpected error occured." }])
|
57
|
+
error_result(request, [{ "message" => custom_message || "An unexpected error occured." }])
|
51
58
|
end
|
52
59
|
|
53
60
|
def on_cache_read(&block)
|
@@ -69,7 +76,7 @@ module GraphQL
|
|
69
76
|
|
70
77
|
def load_plan(request)
|
71
78
|
if @on_cache_read && plan_json = @on_cache_read.call(request)
|
72
|
-
plan =
|
79
|
+
plan = Plan.from_json(JSON.parse(plan_json))
|
73
80
|
|
74
81
|
# only use plans referencing current resolver versions
|
75
82
|
if plan.ops.all? { |op| !op.resolver || @supergraph.resolvers_by_version[op.resolver] }
|
@@ -86,12 +93,12 @@ module GraphQL
|
|
86
93
|
plan
|
87
94
|
end
|
88
95
|
|
89
|
-
def error_result(errors)
|
96
|
+
def error_result(request, errors)
|
90
97
|
public_errors = errors.map! do |e|
|
91
98
|
e.is_a?(Hash) ? e : e.to_h
|
92
99
|
end
|
93
100
|
|
94
|
-
{ "errors" => public_errors }
|
101
|
+
GraphQL::Query::Result.new(query: request, values: { "errors" => public_errors })
|
95
102
|
end
|
96
103
|
end
|
97
104
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module GraphQL::Stitching
|
4
4
|
class Composer
|
5
|
-
class
|
5
|
+
class TypeResolverConfig
|
6
6
|
ENTITY_TYPENAME = "_Entity"
|
7
7
|
ENTITIES_QUERY = "_entities"
|
8
8
|
|
@@ -30,7 +30,7 @@ module GraphQL::Stitching
|
|
30
30
|
entity_type.directives.each do |directive|
|
31
31
|
next unless directive.graphql_name == "key"
|
32
32
|
|
33
|
-
key =
|
33
|
+
key = TypeResolver.parse_key(directive.arguments.keyword_arguments.fetch(:fields))
|
34
34
|
key_fields = key.map { "#{_1.name}: $.#{_1.name}" }
|
35
35
|
field_path = "#{location}._entities"
|
36
36
|
|
@@ -38,7 +38,7 @@ module GraphQL::Stitching
|
|
38
38
|
memo[field_path] << new(
|
39
39
|
key: key.to_definition,
|
40
40
|
type_name: entity_type.graphql_name,
|
41
|
-
arguments: "representations: { #{key_fields.join(", ")},
|
41
|
+
arguments: "representations: { #{key_fields.join(", ")}, #{TYPENAME}: $.#{TYPENAME} }",
|
42
42
|
)
|
43
43
|
end
|
44
44
|
end
|
@@ -2,13 +2,19 @@
|
|
2
2
|
|
3
3
|
module GraphQL::Stitching
|
4
4
|
class Composer
|
5
|
-
class
|
5
|
+
class ValidateTypeResolvers < BaseValidator
|
6
6
|
|
7
7
|
def perform(supergraph, composer)
|
8
|
+
root_types = [
|
9
|
+
supergraph.schema.query,
|
10
|
+
supergraph.schema.mutation,
|
11
|
+
supergraph.schema.subscription,
|
12
|
+
].tap(&:compact!)
|
13
|
+
|
8
14
|
supergraph.schema.types.each do |type_name, type|
|
9
15
|
# objects and interfaces that are not the root operation types
|
10
16
|
next unless type.kind.object? || type.kind.interface?
|
11
|
-
next if
|
17
|
+
next if root_types.include?(type)
|
12
18
|
next if type.graphql_name.start_with?("__")
|
13
19
|
|
14
20
|
# multiple subschemas implement the type
|