My responses from GraphQL have to follow a particular format of
{
data:{}
errors:[{}]
extensions:{}
}
However, I am uncertain how to respond with extensions from my methods. I am using graphql-spring-boot which pulls in graphql-java, graphql-java-tools, and graphql-java-servlet.
I understand that my results from a query/mutation method will be wrapped in the data object, and if any exceptions were thrown they'll be wrapped in errors.
If I have a GraphQL Schema defined as
type Query {
someQuery(input: String!) : String!
}
and a corresponding Java method
public String someQuery(String input) {
return "Hello, world!";
}
The GraphQL response will be
{
data: { "Hello, world!"}
}
I would like to know how I am able to add extensions to my GraphQL response so that the output is as:
{
data: {"Hello, world!"}
extensions: { <something>}
}