2

There's total mess with GraphQL and Java (Spring). There are multiple projects, and multiple examples, but totally inconsistent.

What I understand Spring Boot should gives is OOTB working solution, and (to some extent) it works like this. Project which gives you such experience is on Github https://github.com/graphql-java-kickstart. Especially https://github.com/graphql-java-kickstart/graphql-spring-boot gives you possibility to create schema, make resolver and everything else is done automatically.

Problem is when you try to replace resolver - which seems like very simply datafetcher - with custom datafetcher. As I know there's no possibility to make asynchronous resolver, or batched resolver - you have to make datafetcher.

To make custom datafetchers one needs to make custom wiring etc, replacing spring-boot solution, or using it somehow (how?). There's no single point of true, how to do that properly. I even found that BatchedDataFetcher are deprecated(!) before they even get a good Spring Boot support/example (see: GraphQL Java: Using @Batched DataFetcher)

Because of that I even don't know where to look for solution. What I would welcome to see is to have an example which has:

  • Spring Boot support
  • asynchronous/parallel datafetcher
  • batched datafetcher
  • connecting multiple services with GraphQL endpoints (maybe out of scope)
  • paging/filtering
0

2 Answers 2

6

Anyway, the answer is: use graphql-java-kickstart projects, as those from https://www.graphql-java.com/ are outdated. This fact is very misleading and should be stated somewhere.

Not really. graphql-java is only GraphQL java implementation that I know so far. It defines DataFetcher. It is the core library while other projects that you find such as java-kickstart (or to be more precise its graphql-java-tool) is built on top of the graphql-java and it defines its own implementation of the DataFetcher which is called Resolver.

In the end , the Resolver is just a DataFetcher.

You can find more related information about these two projects in this blog post.

So if you want to have the most flexibility when building the GraphQL server , use graphql-java . On the other hand , if you like the opinionated way that is used by graphql-java-tool , uses it.

Sign up to request clarification or add additional context in comments.

1 Comment

Tools project has also some Spring examples which are quite old. As I use Spring, it was very hard to understand, why Kickstarter libraries doesn't play with it. The fact that graphql-java promotes old examples on their web pages, and don't tell anything about Kickstarter project, is difficult to understand.
2

My question was caused by 2 different frameworks which works with graphql-java. Few days later I know that days of datafetchers are gone (which is promoted on https://www.graphql-java.com/tutorials/getting-started-with-spring-boot/).

Now, if you want to go simply, you can make resolvers and you're done: https://github.com/graphql-java-kickstart If you want go deeper, you should make dataloaders: https://github.com/graphql-java/java-dataloader

Anyway, the answer is: use graphql-java-kickstart projects, as those from https://www.graphql-java.com/ are outdated. This fact is very misleading and should be stated somewhere.

1 Comment

This is good info, but did you ever find good examples? I’m also somewhat lost about what the current ‘best practice’ for batching requests, n+1, etc is within the Java GraphQL ecosystem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.