diff --git a/lib/apollo-federation/federated_document_from_schema_definition.rb b/lib/apollo-federation/federated_document_from_schema_definition.rb index 8d2f13d7d..cb58fabeb 100644 --- a/lib/apollo-federation/federated_document_from_schema_definition.rb +++ b/lib/apollo-federation/federated_document_from_schema_definition.rb @@ -101,7 +101,7 @@ def merge_directives(node, type) def directive_name(directive) if schema.federation_2? && !Schema::IMPORTED_DIRECTIVES.include?(directive[:name]) - "#{schema.link_namespace}__#{directive[:name]}" + "#{schema.default_link_namespace}__#{directive[:name]}" else directive[:name] end diff --git a/lib/apollo-federation/schema.rb b/lib/apollo-federation/schema.rb index ba7e6d24e..e06a79d43 100644 --- a/lib/apollo-federation/schema.rb +++ b/lib/apollo-federation/schema.rb @@ -7,7 +7,7 @@ module ApolloFederation module Schema - IMPORTED_DIRECTIVES = ['inaccessible', 'tag'].freeze + IMPORTED_DIRECTIVES = ['inaccessible', 'tag', 'composeDirective'].freeze def self.included(klass) klass.extend(CommonMethods) @@ -16,9 +16,11 @@ def self.included(klass) module CommonMethods DEFAULT_LINK_NAMESPACE = 'federation' - def federation(version: '1.0', link: {}) + def federation(version: '1.0', default_link_namespace: nil, links: [], compose_directives: []) @federation_version = version - @link = { as: DEFAULT_LINK_NAMESPACE }.merge(link) + @default_link_namespace = default_link_namespace + @links = links + @compose_directives = compose_directives end def federation_version @@ -37,8 +39,8 @@ def federation_sdl(context: nil) output end - def link_namespace - @link ? @link[:as] : find_inherited_value(:link_namespace) + def default_link_namespace + @default_link_namespace || find_inherited_value(:default_link_namespace, DEFAULT_LINK_NAMESPACE) end def query(new_query_object = nil) @@ -62,14 +64,47 @@ def original_query @orig_query_object || find_inherited_value(:original_query) end + def compose_directives + @compose_directives || find_inherited_value(:compose_directives, []) + end + + def links + @links || find_inherited_value(:links, []) + end + + def all_links + imported_directives = IMPORTED_DIRECTIVES + default_link = { + url: 'https://specs.apollo.dev/federation/v2.3', + import: imported_directives, + } + default_link[:as] = default_link_namespace if default_link_namespace != DEFAULT_LINK_NAMESPACE + [default_link, *links] + end + def federation_2_prefix - federation_namespace = ", as: \"#{link_namespace}\"" if link_namespace != DEFAULT_LINK_NAMESPACE + schema = ['extend schema'] + + all_links.each do |link| + link_str = ' @link(' + link_str += "url: \"#{link[:url]}\"" + link_str += ", as: \"#{link[:as]}\"" if link[:as] + if link[:import] + imported_directives = link[:import].map { |d| "\"@#{d}\"" }.join(', ') + link_str += ", import: [#{imported_directives}]" + end + link_str += ')' + schema << link_str + end + + compose_directives.each do |directive| + schema << " @composeDirective(name: \"@#{directive}\")" + end - <<~SCHEMA - extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3"#{federation_namespace}, import: [#{(IMPORTED_DIRECTIVES.map { |directive| "\"@#{directive}\"" }).join(', ')}]) + schema << '' + schema << '' - SCHEMA + schema.join("\n") end def schema_entities diff --git a/spec/apollo-federation/service_field_v2_spec.rb b/spec/apollo-federation/service_field_v2_spec.rb index bb7fd83f1..fa3112e90 100644 --- a/spec/apollo-federation/service_field_v2_spec.rb +++ b/spec/apollo-federation/service_field_v2_spec.rb @@ -115,7 +115,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product { upc: String! @@ -128,6 +128,98 @@ def execute_sdl(schema) ) end + it 'returns the federation SDL with multiple links for the schema' do + product = Class.new(base_object) do + graphql_name 'Product' + + field :upc, String, null: false + end + + query_obj = Class.new(base_object) do + graphql_name 'Query' + + field :product, product, null: true + end + + schema = Class.new(base_schema) do + query query_obj + federation version: '2.3', + links: [{ + url: 'https://specs.example.com/federation/v2.3', + import: ['test'], + }] + end + + expect(execute_sdl(schema)).to match_sdl( + <<~GRAPHQL, + extend schema + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) + @link(url: "https://specs.example.com/federation/v2.3", import: ["@test"]) + + type Product { + upc: String! + } + + type Query { + product: Product + } + GRAPHQL + ) + end + + it 'returns the federation SDL with compose directives for the schema' do + complexity_directive = Class.new(GraphQL::Schema::Directive) do + graphql_name 'complexity' + argument :fixed, Integer, required: true + description 'complexity of the field' + locations GraphQL::Schema::Directive::FIELD_DEFINITION + end + + product = Class.new(base_object) do + graphql_name 'Product' + + field :upc, String, null: false + end + + query_obj = Class.new(base_object) do + graphql_name 'Query' + + field :product, product, null: true, directives: { complexity_directive => { fixed: 1 } } + end + + schema = Class.new(base_schema) do + query query_obj + federation version: '2.3', + links: [{ + url: 'https://specs.example.com/federation/v2.3', + import: [complexity_directive.graphql_name], + }], + compose_directives: [complexity_directive.graphql_name] + end + + expect(execute_sdl(schema)).to match_sdl( + <<~GRAPHQL, + extend schema + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) + @link(url: "https://specs.example.com/federation/v2.3", import: ["@complexity"]) + @composeDirective(name: "@complexity") + + """ + complexity of the field + """ + directive @complexity(fixed: Int!) on FIELD_DEFINITION + + type Product { + upc: String! + } + + type Query { + product: Product @complexity(fixed: 1) + } + GRAPHQL + ) + end + it 'returns valid SDL for type extensions' do product = Class.new(base_object) do graphql_name 'Product' @@ -150,7 +242,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @federation__extends { upc: String! @@ -186,7 +278,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Position @federation__shareable { x: Int! @@ -223,7 +315,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Position @inaccessible { x: Int! @@ -260,7 +352,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Position @tag(name: "private") { x: Int! @@ -291,13 +383,13 @@ def execute_sdl(schema) schema = Class.new(base_schema) do query query_obj - federation version: '2.0', link: { as: 'fed2' } + federation version: '2.0', default_link_namespace: 'fed2' end expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @fed2__extends { upc: String! @@ -327,13 +419,13 @@ def execute_sdl(schema) schema = Class.new(base_schema) do query query_obj - federation version: '2.0', link: { as: 'fed2' } + federation version: '2.0', default_link_namespace: 'fed2' end expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible", "@tag", "@composeDirective"]) type Position @fed2__shareable { x: Int! @@ -364,13 +456,13 @@ def execute_sdl(schema) schema = Class.new(base_schema) do query query_obj - federation version: '2.0', link: { as: 'fed2' } + federation version: '2.0', default_link_namespace: 'fed2' end expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible", "@tag", "@composeDirective"]) type Position @inaccessible { x: Int! @@ -401,13 +493,13 @@ def execute_sdl(schema) schema = Class.new(base_schema) do query query_obj - federation version: '2.0', link: { as: 'fed2' } + federation version: '2.0', default_link_namespace: 'fed2' end expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible", "@tag", "@composeDirective"]) type Position @tag(name: "private") { x: Int! @@ -437,13 +529,13 @@ def execute_sdl(schema) schema = Class.new(base_schema) do query query_obj - federation version: '2.0', link: { as: 'fed2' } + federation version: '2.0', default_link_namespace: 'fed2' end expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @fed2__key(fields: "upc") { upc: String! @@ -468,13 +560,13 @@ def execute_sdl(schema) schema = Class.new(base_schema) do orphan_types product - federation version: '2.0', link: { as: 'fed2' } + federation version: '2.0', default_link_namespace: 'fed2' end expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @fed2__extends @fed2__key(fields: "upc") { price: Int @@ -495,13 +587,13 @@ def execute_sdl(schema) schema = Class.new(base_schema) do orphan_types product - federation version: '2.3', link: { as: 'fed2' } + federation version: '2.3', default_link_namespace: 'fed2' end expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @fed2__interfaceObject @fed2__key(fields: "id") { id: ID! @@ -550,7 +642,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Book implements Product { upc: String! @@ -602,7 +694,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Book implements Product { upc: String! @@ -665,7 +757,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Book implements Product @federation__extends @federation__key(fields: "upc") { upc: String! @federation__external @@ -709,7 +801,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Book { upc: String! @@ -747,7 +839,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Book { upc: String! @@ -785,7 +877,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) enum ProductType @tag(name: "private") { BOOK @@ -822,7 +914,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) enum ProductType @inaccessible { BOOK @@ -863,7 +955,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product { upc: UPC! @@ -909,7 +1001,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product { upc: UPC! @@ -959,7 +1051,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) """ Autogenerated return type of CreateProduct. @@ -1014,7 +1106,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) """ Autogenerated return type of CreateProduct. @@ -1069,7 +1161,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) """ Autogenerated return type of CreateProduct. @@ -1124,7 +1216,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) """ Autogenerated return type of CreateProduct. @@ -1173,7 +1265,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) """ Autogenerated return type of CreateProduct. @@ -1218,7 +1310,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) """ Autogenerated return type of CreateProduct. @@ -1257,7 +1349,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @federation__key(fields: "upc") { upc: String! @@ -1288,7 +1380,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @federation__key(fields: "upc") { upc: String! @@ -1316,7 +1408,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @federation__key(fields: "upc") @federation__key(fields: "name") { name: String @@ -1342,7 +1434,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @federation__key(fields: "upc", resolvable: false) { upc: String! @@ -1367,7 +1459,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @federation__key(fields: "upc") { upc: String! @@ -1394,7 +1486,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @federation__extends @federation__key(fields: "upc") { price: Int @@ -1421,7 +1513,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @federation__interfaceObject @federation__key(fields: "id") { id: ID! @@ -1452,7 +1544,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Position { x: Int! @federation__shareable @@ -1488,7 +1580,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Position { x: Int! @inaccessible @@ -1524,7 +1616,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Position { x: Int! @tag(name: "private") @@ -1560,7 +1652,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Position { x: Int! @tag(name: "private") @tag(name: "protected") @@ -1612,7 +1704,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product { type: ProductType! @@ -1668,7 +1760,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product { type: ProductType! @@ -1724,7 +1816,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product { type: ProductType! @@ -1760,7 +1852,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @federation__extends @federation__key(fields: "id") { id: ID! @@ -1796,7 +1888,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @federation__extends @federation__key(fields: "upc") { price: Int @@ -1831,7 +1923,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @federation__extends @federation__key(fields: "upc") { price: Int @federation__external @@ -1860,7 +1952,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @federation__key(fields: "productId") { productId: String! @@ -1888,7 +1980,7 @@ def execute_sdl(schema) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @federation__extends @federation__key(fields: "product_id") { options: [String!]! @federation__requires(fields: "my_id") @@ -1921,7 +2013,7 @@ def self.visible?(context) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @federation__extends @federation__key(fields: "upc") { upc: String! @federation__external @@ -1949,7 +2041,7 @@ def self.visible?(context) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @federation__key(fields: "id") { id: ID! @@ -1973,7 +2065,7 @@ def self.visible?(context) end new_base_schema = Class.new(base_schema) do - federation version: '2.0', link: { as: 'fed2' } + federation version: '2.0', default_link_namespace: 'fed2' end schema = Class.new(new_base_schema) do @@ -1983,7 +2075,7 @@ def self.visible?(context) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @fed2__extends { upc: String! @@ -2011,7 +2103,7 @@ def self.visible?(context) end new_base_schema = Class.new(base_schema) do - federation version: '2.0', link: { as: 'fed2' } + federation version: '2.0', default_link_namespace: 'fed2' query query_obj end @@ -2020,7 +2112,7 @@ def self.visible?(context) expect(execute_sdl(schema)).to match_sdl( <<~GRAPHQL, extend schema - @link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible", "@tag"]) + @link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible", "@tag", "@composeDirective"]) type Product @fed2__extends { upc: String!