I have a basic Java entity class.
public class Result {
String resultTitle;
String resultDecription;
}
This class is returned in a GraphQL query
@GraphQLQuery(name = "getResult")
public Result getResult() {
Result result = //get result, e.g. from DB
return result;
}
This works fine so far. Now I want to return one additional attribute in the GraphQL query. But that additonal attribute is very costly to calculate. So I only want to return it, when the GraphQL client actually requests it in his query like so:
query { getResult() { resultTitle resultDecription } }
<== do not execute the costly calculationquery { getResult() { resultTitle resultDecription costlyAdditionalProp } }
<== DO execute the costly calculation
Can this be done with graphql-spqr?