We are using graphql-spqr to generate the graphql schema from our Java backend api and model.
Today to get products for example we annotate a methods that looks like that:
@GraphQLQuery
List<Product> allProducts() {...}
We want to avoid creating a new endpoint to retrieve extra fields in Product.
Is there a way to define a resolver for fields that are not part of the model? (annotation or not)
As an example, let's assume our java model for a Product + two end points:
class Product {
String id;
String name;
}
class Frame {
String id;
}
// and some kind of relationship between the two
class ProductToFrame {
String productId;
String frameId
}
List<Product> allProducts();
List<Frame> getFramesByProductId(String productId);
And we want our graphql schema to look like that:
type Product {
id: String
name: String
frames: [Frame]
}
type Frame {
id: String
}