diff --git a/Gemfile b/Gemfile index f706b082f..63d6257c4 100644 --- a/Gemfile +++ b/Gemfile @@ -62,6 +62,7 @@ gem 'graphql-errors', '~> 0.3.0' gem 'graphql-batch', '~> 0.4.0' gem 'batch-loader', '~> 1.4', '>= 1.4.1' gem 'graphql-cache', '~> 0.6.0', git: "https://github.com/stackshareio/graphql-cache" +gem 'apollo-federation', '~> 0.4.0' # gem 'ddtrace', '~> 0.23.3' group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 12f7c4426..a549d1df9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,7 +8,7 @@ GIT GEM remote: https://rubygems.org/ specs: - aasm (5.0.5) + aasm (5.0.6) concurrent-ruby (~> 1.0) actioncable (5.2.3) actionpack (= 5.2.3) @@ -56,16 +56,19 @@ GEM i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.6.0) - public_suffix (>= 2.0.2, < 4.0) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) ansi (1.5.0) + apollo-federation (0.4.0) + google-protobuf + graphql arel (9.0.0) ast (2.4.0) audited (4.9.0) activerecord (>= 4.2, < 6.1) aws-eventstream (1.0.3) - aws-partitions (1.207.0) - aws-sdk-core (3.65.0) + aws-partitions (1.220.0) + aws-sdk-core (3.68.0) aws-eventstream (~> 1.0, >= 1.0.2) aws-partitions (~> 1.0) aws-sigv4 (~> 1.1) @@ -73,11 +76,11 @@ GEM aws-sdk-kms (1.24.0) aws-sdk-core (~> 3, >= 3.61.1) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.46.0) + aws-sdk-s3 (1.48.0) aws-sdk-core (~> 3, >= 3.61.1) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.1) - aws-sdk-sqs (1.21.0) + aws-sdk-sqs (1.22.0) aws-sdk-core (~> 3, >= 3.61.1) aws-sigv4 (~> 1.1) aws-sigv4 (1.1.0) @@ -129,12 +132,12 @@ GEM rdf-rdfxml (~> 2.0) rdf-turtle (~> 2.2) thor (~> 0.19) - bootsnap (1.4.4) + bootsnap (1.4.5) msgpack (~> 1.0) builder (3.2.3) byebug (11.0.1) cancancan (2.3.0) - capybara (3.28.0) + capybara (3.29.0) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) @@ -186,8 +189,8 @@ GEM ebnf (1.1.3) rdf (~> 3.0) sxp (~> 1.0) - edtf (3.0.4) - activesupport (>= 3.0, < 6.0) + edtf (3.0.5) + activesupport (>= 3.0, < 7.0) elasticsearch (6.8.0) elasticsearch-api (= 6.8.0) elasticsearch-transport (= 6.8.0) @@ -206,7 +209,7 @@ GEM multi_json equivalent-xml (0.6.0) nokogiri (>= 1.4.3) - erubi (1.8.0) + erubi (1.9.0) excon (0.62.0) facets (3.1.0) factory_bot (4.11.1) @@ -222,9 +225,9 @@ GEM faraday faraday_middleware (0.12.2) faraday (>= 0.7.4, < 1.0) - faraday_middleware-aws-sigv4 (0.2.4) + faraday_middleware-aws-sigv4 (0.2.5) aws-sigv4 (~> 1.0) - faraday (>= 0.9) + faraday (>= 0.9, < 0.15) fast_jsonapi (1.5) activesupport (>= 4.2) ffi (1.11.1) @@ -237,7 +240,8 @@ GEM git (1.5.0) globalid (0.4.2) activesupport (>= 4.2.0) - graphql (1.9.10) + google-protobuf (3.9.2) + graphql (1.9.12) graphql-batch (0.4.1) graphql (>= 1.3, < 2) promise.rb (~> 0.7.2) @@ -298,7 +302,7 @@ GEM logstash-event (1.2.02) logstash-logger (0.26.1) logstash-event (~> 1.2) - loofah (2.2.3) + loofah (2.3.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -319,14 +323,14 @@ GEM nokogiri (~> 1.8.1) oj (>= 2.8.3) method_source (0.9.2) - mime-types (3.2.2) + mime-types (3.3) mime-types-data (~> 3.2015) - mime-types-data (3.2019.0331) + mime-types-data (3.2019.0904) mimemagic (0.3.3) mini_magick (4.9.5) mini_mime (1.0.2) mini_portile2 (2.3.0) - minitest (5.11.3) + minitest (5.12.2) money (6.13.4) i18n (>= 0.6.4, <= 2) msgpack (1.3.1) @@ -335,14 +339,14 @@ GEM mysql2 (0.4.10) namae (1.0.1) netrc (0.11.0) - nio4r (2.5.0) + nio4r (2.5.2) nokogiri (1.8.5) mini_portile2 (~> 2.3.0) oj (2.18.5) oj_mimic_json (1.0.1) pandoc-ruby (2.0.2) parallel (1.17.0) - parser (2.6.3.0) + parser (2.6.4.1) ast (~> 2.4.0) postrank-uri (1.0.24) addressable (>= 2.4.0) @@ -461,7 +465,7 @@ GEM ruby-progressbar (1.10.1) ruby_dep (1.5.0) safe_yaml (1.0.5) - sentry-raven (2.11.0) + sentry-raven (2.11.3) faraday (>= 0.7.6, < 1.0) shoryuken (4.0.3) aws-sdk-core (>= 2) @@ -469,7 +473,7 @@ GEM thor shoulda-matchers (3.1.3) activesupport (>= 4.0.0) - simple_command (0.0.9) + simple_command (0.1.0) simplecov (0.13.0) docile (~> 1.1.0) json (>= 1.8, < 3) @@ -499,10 +503,10 @@ GEM sxp (1.0.2) rdf (~> 3.0) sysrandom (1.0.5) - temple (0.8.1) + temple (0.8.2) thor (0.20.3) thread_safe (0.3.6) - tilt (2.0.9) + tilt (2.0.10) trollop (2.9.9) turnout (2.5.0) i18n (>= 0.7, < 2) @@ -517,7 +521,7 @@ GEM unicode-display_width (1.5.0) unicode_utils (1.4.0) vcr (3.0.3) - webmock (3.7.0) + webmock (3.7.6) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) @@ -533,6 +537,7 @@ PLATFORMS DEPENDENCIES aasm (~> 5.0, >= 5.0.1) active_model_serializers (~> 0.10.0) + apollo-federation (~> 0.4.0) audited (~> 4.8) aws-sdk-s3 aws-sdk-sqs (~> 1.3) diff --git a/app/graphql/lupo_schema.rb b/app/graphql/lupo_schema.rb index c33928936..f722cd09d 100644 --- a/app/graphql/lupo_schema.rb +++ b/app/graphql/lupo_schema.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class LupoSchema < GraphQL::Schema + include ApolloFederation::Schema + # use(GraphQL::Tracing::DataDogTracing, analytics_enabled: Rails.env.production?) default_max_page_size 250 diff --git a/app/graphql/types/base_field.rb b/app/graphql/types/base_field.rb new file mode 100644 index 000000000..08c0ab247 --- /dev/null +++ b/app/graphql/types/base_field.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +require 'apollo-federation' + +class BaseField < GraphQL::Schema::Field + include ApolloFederation::Field + + #field_class GraphQL::Cache::Field +end diff --git a/app/graphql/types/base_object.rb b/app/graphql/types/base_object.rb index 469f40e04..44be8abc5 100644 --- a/app/graphql/types/base_object.rb +++ b/app/graphql/types/base_object.rb @@ -1,7 +1,9 @@ # frozen_string_literal: true class BaseObject < GraphQL::Schema::Object - field_class GraphQL::Cache::Field + include ApolloFederation::Object + + field_class BaseField def doi_from_url(url) if /\A(?:(http|https):\/\/(dx\.)?(doi.org|handle.test.datacite.org)\/)?(doi:)?(10\.\d{4,5}\/.+)\z/.match?(url)