Skip to content

Commit

Permalink
fix: import @inaccessible directive in Fed v2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
moonflare committed Feb 21, 2023
1 parent a6ee84a commit c81112a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class FederatedDocumentFromSchemaDefinition < GraphQL::Language::DocumentFromSch
'_entities',
'_service',
].freeze
INACCESSIBLE_DIRECTIVE = 'inaccessible'.freeze

def build_object_type_node(object_type)
object_node = super
Expand Down Expand Up @@ -70,7 +71,7 @@ def merge_directives(node, type)
end

def directive_name(directive)
if schema.federation_2?
if schema.federation_2? && directive[:name] != INACCESSIBLE_DIRECTIVE
"#{schema.link_namespace}__#{directive[:name]}"
else
directive[:name]
Expand Down
2 changes: 1 addition & 1 deletion lib/apollo-federation/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def federation_2_prefix

<<~SCHEMA
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3"#{federation_namespace})
@link(url: "https://specs.apollo.dev/federation/v2.3"#{federation_namespace}, import: ["@inaccessible"])
SCHEMA
end
Expand Down
58 changes: 29 additions & 29 deletions spec/apollo-federation/service_field_v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Product {
upc: String!
Expand Down Expand Up @@ -144,7 +144,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Product @federation__extends {
upc: String!
Expand Down Expand Up @@ -180,7 +180,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Position @federation__shareable {
x: Int!
Expand Down Expand Up @@ -217,9 +217,9 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Position @federation__inaccessible {
type Position @inaccessible {
x: Int!
y: Int!
}
Expand Down Expand Up @@ -254,7 +254,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2")
@link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible"])
type Product @fed2__extends {
upc: String!
Expand Down Expand Up @@ -290,7 +290,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2")
@link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible"])
type Position @fed2__shareable {
x: Int!
Expand Down Expand Up @@ -327,9 +327,9 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2")
@link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible"])
type Position @fed2__inaccessible {
type Position @inaccessible {
x: Int!
y: Int!
}
Expand Down Expand Up @@ -363,7 +363,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2")
@link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible"])
type Product @fed2__key(fields: "upc") {
upc: String!
Expand Down Expand Up @@ -394,7 +394,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2")
@link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible"])
type Product @fed2__extends @fed2__key(fields: "upc") {
price: Int
Expand All @@ -421,7 +421,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2")
@link(url: "https://specs.apollo.dev/federation/v2.3", as: "fed2", import: ["@inaccessible"])
type Product @fed2__interfaceObject @fed2__key(fields: "id") {
id: ID!
Expand Down Expand Up @@ -470,13 +470,13 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Book implements Product {
upc: String!
}
interface Product @federation__inaccessible {
interface Product @inaccessible {
upc: String!
}
GRAPHQL
Expand Down Expand Up @@ -533,7 +533,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Book implements Product @federation__extends @federation__key(fields: "upc") {
upc: String! @federation__external
Expand Down Expand Up @@ -573,7 +573,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Product @federation__key(fields: "upc") {
upc: String!
Expand Down Expand Up @@ -604,7 +604,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Product @federation__key(fields: "upc") {
upc: String!
Expand Down Expand Up @@ -632,7 +632,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Product @federation__key(fields: "upc") @federation__key(fields: "name") {
name: String
Expand Down Expand Up @@ -660,7 +660,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Product @federation__extends @federation__key(fields: "upc") {
price: Int
Expand All @@ -687,7 +687,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Product @federation__interfaceObject @federation__key(fields: "id") {
id: ID!
Expand Down Expand Up @@ -718,7 +718,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Position {
x: Int! @federation__shareable
Expand Down Expand Up @@ -754,10 +754,10 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Position {
x: Int! @federation__inaccessible
x: Int! @inaccessible
y: Int!
}
Expand Down Expand Up @@ -786,7 +786,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Product @federation__extends @federation__key(fields: "id") {
id: ID!
Expand Down Expand Up @@ -822,7 +822,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Product @federation__extends @federation__key(fields: "upc") {
price: Int
Expand Down Expand Up @@ -857,7 +857,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Product @federation__extends @federation__key(fields: "upc") {
price: Int @federation__external
Expand Down Expand Up @@ -886,7 +886,7 @@ def execute_sdl(schema)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Product @federation__key(fields: "productId") {
productId: String!
Expand Down Expand Up @@ -914,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")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Product @federation__extends @federation__key(fields: "product_id") {
options: [String!]! @federation__requires(fields: "my_id")
Expand Down Expand Up @@ -947,7 +947,7 @@ def self.visible?(context)
expect(execute_sdl(schema)).to match_sdl(
<<~GRAPHQL,
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.3")
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@inaccessible"])
type Product @federation__extends @federation__key(fields: "upc") {
upc: String! @federation__external
Expand Down

0 comments on commit c81112a

Please sign in to comment.