Absinthe.Federation.Notation.provides_fields
You're seeing just the macro
provides_fields
, go back to Absinthe.Federation.Notation module for more information.
Adds the @provides
directive which is used to annotate the expected returned fieldset
from a field on a base type that is guaranteed to be selectable by the gateway.
Example
object :review do
key_fields("id")
field :id, non_null(:id)
field :product, :product do
provides_fields("name")
end
end
object :product do
extends()
key_fields("upc")
field :upc, :string do
external()
end
field :name, :string do
external()
end
end
SDL Output
type Review @key(fields: "id") {
product: Product @provides(fields: "name")
}
type Product @key(fields: "upc") @extends {
upc: String @external
name: String @external
}
When fetching Review.product
from the Reviews service,
it is possible to request the name
with the expectation that the Reviews service
can provide it when going from review to product. Product.name
is an external field
on an external type which is why the local type extension of Product
and annotation of name
is required.