I am trying to federate two of my micro services with apollo gql federation 2. I have successfully connected the two services through the federation with the following schemas:
Subgraph1 - Product
type Product @key(fields: "id") {
id: ID!
title: String!
description: String
price: Int!
category: [Category!]
}
type Category @key(fields: "id") {
id: ID!
}
type Query {
product(id: ID!): Product
}
Subgraph 2 - Category
type Category @key(fields: "id") {
id: ID!
title: String
}
and the following query
query Product($productId: ID!) {
product(id: $productId) {
id
title
category {
id
title
}
}
}
gives a desired result
However, what if I wanted to add some filter on the returned categories for a given product. Lets say I only wanted to have the ones with title "sport", so the query would look like this instead:
query Product($productId: ID!) {
product(id: $productId) {
id
title
category(searchTerm: "sport") {
id
title
}
}
}
A normal way of doing the input argument would be simply just
type Product @key(fields: "id") {
id: ID!
title: String!
description: String
price: Int!
category(searchTerm: String): [Category!]
}
Is this achievable when federating the services? I am not sure how the input field is provided to the second subgraph?
I tried to add the input as a part of the type in the first subgraph, however it does not seem to pass the search term to the next graph.