0

I have a Spring Boot application with Spring for GraphQL library and I need to modify the returned object. So I created and registered a projection class referring to my bean method:

public interface MyEntityProjection {

    @Value("#{@myBean.getName()}")
    public String getName();
}

But this results in org.springframework.expression.spel.SpelEvaluationException: EL1057E: No bean resolver registered in the context to resolve access to bean 'myBean' when the query is run. Probably a bean resolver needs to be registered somehow but there is no info in the documentation https://docs.spring.io/spring-graphql/docs/1.0.0-SNAPSHOT/reference/html/

Simple application illustrating my problem: https://github.com/omichal/spring-graphq-no-bean-resolver

Ondřej Míchal
  • 573
  • 2
  • 5
  • 14

1 Answers1

0

This is a very opinionated behaviour from the framework itself unfortunately.
You have to prepend your spel with target. In your case it will be:

@Value("#{target.name}")

By default the framework will call the original bean getName method - you don't need to put the get.

Gonçalo
  • 561
  • 5
  • 14