GraphQL Java Cheat Sheet

Tomek PoniatowiczTomek Poniatowicz

A GraphQL Java Cheat Sheet to help you understand what is what in GraphQL Java world. You might find it useful if you:

  • Want to learn GraphQL Java
  • Feel confused by all the Java GraphQL libraries
  • Want to try GraphQL Java in your project, but not sure how to start

Gradle or Maven?

Gradle and Maven are the most popular build automation tools. Which one you should choose? I can not provide you an answer to that question as this decision is to a large extent up to you and it depends on variables like your project's size or how much customization it needs. The tools like Spring and the constantly increasing amount of integration make it's quite a personal decision. As both approaches have their strengths and weaknesses, I hope this short summary can help you choose the right one for your project.

GradleMaven
builds approachbased on a graph of task dependenciesbased on a fixed and linear model of phases
dynamic and transitive dependenciesyesyes
artifact repositoriesJCenterMaven Central
private company repositoryyesyes
custom rules, resolving version conflictsyesno
advance task orderingsyesno
administering build infrastructureuses wrappers that accept auto provisioningrequire an extension to support self-provisioning builds

To sum up, Gradle is much more powerful than Maven, but in many cases, you won't need to use its fancy features. If you are working on a small project you should consider Maven, if it's a big enterprise application Gradle seems to be the right choice. In the end, it's your personal choice.

Libraries

There are a couple of GraphQL Java related libraries. The only library that is strictly required is a graphql-java which is the GraphQL implementation itself, but there are many others that you might find useful:

  • graphql-java: The alpha and omega of any project, the GraphQL Java implementation itself.

  • graphql-java-tools: The library that allows you to use the GraphQL schema language to build your GraphQL schema. It's inspired by Apollo's graphql-tools, it parses the given GraphQL schema and allows you to bring your own object to fill in the implementations.

  • graphql-spring-boot: A lib that contains various Spring Boot starters to enable GraphQL related services and features.

  • graphql-java-servlet: The implementation of GraphQL Java Servlet including support for popular libraries like Relay.js, Apollo, and OSGi out of the box; wraps the Java implementation of GraphQL provided by GraphQL Java.

  • graphql-java-annotations: The library that offers an annotations-based syntax for GraphQL schema definition.

DEV.TO GraphQL Java articles

Tutorials and other resources

Video tutorials:

Spring Boot with GraphQL Query Example - Tech Primers

Building a GraphQL Server with Kotlin and graphql-java - Michael Hunger

Developing and maintaining a Java GraphQL back-end - Bojan Tomic

⚡ Speed up your GraphQL API development

The GraphQL Editor is a supportive tool for both advanced GraphQL users as well as those taking their first steps with GraphQL APIs. Our all-in-one development environment for GraphQL will help you build, manage & deploy your GraphQL API much faster thanks to dozens of built-in micro features. Its graphical interface will also fix communication within your product team. Visualization is the key!

Try it for free