graphql-gradle-plugin is a Gradle Plugin for GraphQL, based on graphql-java. It accelerates the development for both the client and the server, by generating the Java code. It allows a quicker development when in contract-first approach, by avoiding to code the boilerplate code.
I've been trying to get this plugin working in client mode for the last week or so and I am able to generate my client code okay and start writing classes using the generated sources, but when starting up my SpringBoot application I get this error:
***************************
APPLICATION FAILED TO START
***************************
Description:
Field graphQL in graphql.spring.web.servlet.components.DefaultGraphQLInvocation required a bean of type 'graphql.GraphQL' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'graphql.GraphQL' in your configuration.
I was able to resolve other similar errors with GraphQLConfiguration.class by doing a component scan in my main class like so:
@SpringBootApplication(scanBasePackageClasses = { GraphQLConfiguration.class })
public class BookingMigrationServiceApplication{
public static void main(String[] args) {
SpringApplication.run(BookingMigrationServiceApplication.class, args);
}
}
but doing the same for graphql.GraphQL hasn't resolved the issue. I've tried creating a new GraphQL object and returning it as a @Bean, but it doesn't look like it is annotation with any sort of @Component or @Service etc., and it is not one of the generated classes. It also requires building up a whole new GraphQLSchema object which I'm pretty sure I shouldn't need to do.
I've tried looking through your tutorial and samples and I can't actually see this class used anywhere in the manner that I am attempting to. I believe I'm missing some configuration but I'm not sure how. I'm also trying to stick with constructor injection rather that field injection with @Autowired, and I don't know if this is supported.
All I'm really trying to do is execute a single Mutation to retrieve a security token, and then a regular Query to retrieve some JSON from a third-party endpoint.
I've been trying to get this plugin working in client mode for the last week or so and I am able to generate my client code okay and start writing classes using the generated sources, but when starting up my SpringBoot application I get this error:
I was able to resolve other similar errors with
GraphQLConfiguration.class
by doing a component scan in my main class like so:but doing the same for
graphql.GraphQL
hasn't resolved the issue. I've tried creating a newGraphQL
object and returning it as a @Bean, but it doesn't look like it is annotation with any sort of@Component
or@Service
etc., and it is not one of the generated classes. It also requires building up a whole new GraphQLSchema object which I'm pretty sure I shouldn't need to do.I've tried looking through your tutorial and samples and I can't actually see this class used anywhere in the manner that I am attempting to. I believe I'm missing some configuration but I'm not sure how. I'm also trying to stick with constructor injection rather that field injection with @Autowired, and I don't know if this is supported.
All I'm really trying to do is execute a single Mutation to retrieve a security token, and then a regular Query to retrieve some JSON from a third-party endpoint.
Do you have any idea where I'm going wrong?