extend schema
@link(url: "https://specs.apollo.dev/federation/v2.11")
@link(
url: "https://specs.apollo.dev/connect/v0.4"
import: ["@connect", "@source"]
)
@source(
name: "products-api"
http: { baseURL: "https://ecommerce.demo-api.apollo.dev/" }
)
type Book {
upc: ID!
title: String!
author: Person
}
type Film {
upc: ID!
title: String!
director: Person
}
union Product = Book | Film
type User @connect(
source: "products-api"
http: { GET: "/users/{$this.id}" }
selection: "id name"
) {
id: ID!
name: String
}
type Query {
products: [Product]
@connect(
source: "products-api"
http: { GET: "/products" }
selection: """
upc
... category->match(
["book", {
__typename: "Book",
title,
author { id },
}],
["film", $ {
__typename: $("Film")
title
director { id }
}],
[@, null],
)
"""
)
}