'SpringBoot GraphQL mutation giving error No Root resolvers for query type 'Query' found
Am getting the error No Root resolvers for query type 'Query' found when using mutation in SpringBoot with GraphQL. The queries are working fine , but on adding the GraphQLMutationResolver, it is giving the error on Spring Boot startup.
Kindly advise.
.graphqls file
type Query {
allBooks: [Book]
getBookByIsn(isn: Int): Book
allPublishers: [Publisher]
}
type Book {
isn: Int
title: String
author: String
publishedDate: String
publisher: Publisher!
}
type Publisher {
pId : Int
publisherName: String
address: String
}
input CreatePublisher {
pId : Int
publisherName: String
address: String
}
type Mutation {
addPublisher(input: CreatePublisher!): Publisher
}
Mutation Resolver
@Component
public class PublisherMutation implements GraphQLMutationResolver{
@Autowired
private PublisherRepository publisherRepository;
@Transactional
public Publisher addPublisher(CreatePublisher createPublisher ) {
Publisher publisher = new Publisher(createPublisher.getPId(), createPublisher.getPublisherName(), createPublisher.getAddress());
publisherRepository.save(publisher);
return publisher;
}
}
Solution 1:[1]
Done, solved by adding a newTypeWiring of type Mutation for Create
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | astar |
