Hey!
We are pretty new to the federated graph approach and hope to have some feedback if we are trying to complicate too much by splitting it out into smaller entities.
Examples:
We have a Ticket:
type Ticket @key(fields: "id") {
id: ID!
ownerId: ID!
categoryId: ID!
title: String!
data: String
startDate: DateTime!
endDate: DateTime!
venue: String
county: String
section: String
seat: String
}
extend type Category @key(fields: "id") {
id: ID! @external
tickets: [Ticket!]!
}
And we have a Category
type Category @key(fields: "id") {
id: ID!
name: String!
type: CategoryType!
}
extend type Ticket @key(fields: "id") {
id: ID! @external
categoryId: ID! @external
category: Category @requires(fields: "categoryId")
}
We now need to implement a way to list Products for sale, and set listPrice etc. And in the future even bids. So my idea was to create a new federated service that handles listedProducts
like below:
type ListedProduct @key(fields: "id") {
id: ID!
sellingPrice: Float!'
ticketForSale: Boolean!
}
extend type Product @key(fields: "id") {
id: ID! @external
ticketForSale: Boolean!
sellingPrice: Float!
}
So far, so good. But where I run into troubles is where I would want to render only listedProducts under the Category
entity. This would need a 3 way reference in order to resolve, how would I do this without communicating directly between the services?
Expected outcome:
query {
category() {
// Only listedProducts should render here, but with the type of a Product.
products() {
id
....
}
}
}