1

I have GraphQL + SpringBoot + MongoDB application, with graphql.java.kickstart.springboot ,and I'm having performance issues. The walking skeleton of this application was done the last year and I received it as it is. I'd like to add DataLoaders / BatchDataLoaders (better) to improve the performance and to avoid to query the DB overtime for similar requests. Looking at DataLoaders examples I see quite different implementations from the one I have. I have a QueryResolver class that calls the Service which calls the Repository. The result is exposed from here, not handled by some Resolvers.

@Component
@Slf4j
@AllArgsConstructor
@NoArgsConstructor
public class Query implements GraphQLQueryResolver {
    @Autowired
    ProjectService projectService;

    public Iterable<ProjectDao> listProjects(String name, Sort orderByInput) {
        return projectService.getProjects(name, orderByInput);
    }
}

Now I don't understand if this is a wrong approach in order to add the DataLoaders. Here I found a question with a similar implementation, but then he seems to have changed looking at this answer. Changing the whole code would be time-consuming and I really hope I'm just missing something. Do you have any tips or docs to suggest? Thank you so much in advance!

Barbi
  • 139
  • 1
  • 11
  • Define "performance issues". Have you profiled the application? What were the results? What specific performance goals are you looking achieve? – Michael May 18 '22 at 11:13
  • Hi @Michael , the performance issues I'm facing are about the classic N+1 problem, I have very large data to load and this slows down a lot the application whenever I request them. The problems are the first ones which pops up if you look for GraphQL performance, eg. [link]https://blog.softwaremill.com/graphql-dataloader-in-spring-boot-singleton-or-request-scoped-16699436f680 . What do you mean by "Have you profiled the application"? Thank you! – Barbi May 18 '22 at 12:20

0 Answers0