'getContext alternative for graphql.schema.DataFetchingEnvironment

I'm using the graphql-java-kickstart library in Spring Boot and have some code like so:

class MyResolver implements GraphQLQueryResolver {
    public String helloWorld(DataFetchingEnvironment env) {
        // this works!!
        CustomGraphQLContext context = env.getContext();
        return "Hello world";
    } 
}

I've built the context elsewhere using the GraphQLServletContextBuilder.

The problem is that getContext is deprecated. It says to alternatively use getGraphQLContext, but it's currently null for me. How do I get it populated? If I need to override the ExecutionInput, where do I do that?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source