I am trying to get result when I query like below in fusion gateway, basically join of Product and Review like for each product get the review details for each product,I know Fusion is in .Net but I thinks as long as introspection work it can work with spring boot graphql service also, so I tried to use @lookup for my use case running query like this way :
query Products {
products {
id
name
reviews {
comment
productId
rating
}
}
}
individual subgraph data fetching is working but unable to run above query, getting below error
{
"errors": [
{
"message": "Unexpected Execution Error"
}
]
}
-----------------------------------------------------
product subgraph schema.graphqls
directive @lookup(by: String) on FIELD_DEFINITION
type Product
{
id: ID!
name: String
}
type Query
{
products: [Product]
productById(id: ID!): Product @lookup(by: "id")
}
-----------------------------
review subgraph schema.graphqls
directive @lookup(by: String) on FIELD_DEFINITION
type Review
{
productId: ID!
rating: Int
comment: String
}
type Query
{
reviews: [Review]
reviewsByProductId(productId: ID!): [Review!]! @lookup(by: "productId")
}
type Product {
id: ID!
}
extend type Product {
reviews: [Review!]! @lookup(by: "productId")
}
both the subgraphs I am running in spring boot graphql and merging these subgraphs using fusion gateway
tried @lookup in schema to make the join and byId resolver
I was expecting to get
{
"data": {
"products": [
{
"id": "1",
"name": "Product A",
"reviews": [
{ "comment": "Excellent", "productId": "1", "rating": 5 },
{ "comment": "Very Good", "productId": "1", "rating": 4 }
]
},
{
"id": "2",
"name": "Product B",
"reviews": [
{ "comment": "Average", "productId": "2", "rating": 3 }
]
}
]
}
}