Composition error when there are no types for union _Entity
kzlsakal opened this issue · 0 comments
I came across this error while testing @apollo/gateway 2.0 with federated subgraphs and using mix task absinthe.federation.schema.sdl
.
If we use Absinthe.Federation.Notation
on a schema that does not introduce an extendable type, or does not extend a type from another subgraph, there are no types for union _Entity
and we get the following composition error from the gateway:
[service_a] Unknown type "_Entity".
[service_a] Union type _Entity must define one or more member types.
Examples
The following schema will result in composition error because there are no types for union _Entity
:
defmodule SchemaWithoutExtendedTypes do
use Absinthe.Schema
use Absinthe.Federation.Schema
query do
field :test, :string
end
end
The following schema will do just fine:
defmodule SchemaWithExtendableType do
use Absinthe.Schema
use Absinthe.Federation.Schema
query do
field :foo, :bar
end
object :bar do
key_fields("id")
field :id, :string
end
end
The following schema will have a successful subraph composition. The supergraph composition on the gateway level will only fail if there are no other services providing this type as an extendable type, which is expected.
defmodule SchemaWithExtendedTypeFromAnotherSubgraph do
use Absinthe.Schema
use Absinthe.Federation.Schema
query do
field :foo, :bar
end
object :bar do
key_fields("id")
extends()
field :id, non_null(:id), do: external()
end
end