π Welcome to Data loaders with Java & DGS!
We're excited you're here! Together we'll set our sights on improving performance in our GraphQL applications, zooming in on the best practice of using data loaders. We've got lots of hands-on opportunities ahead, and you'll find quizzes and challenges to test your understanding as we tackle this topic.
In this course, we'll address one of the sneaky performance problems that can appear in GraphQL projects: the n+1 problem. Once we understand how this problem occurs, we'll implement the solution using data loaders. We'll walk through the steps of implementing and using data loaders in our DGS project, and see the direct effect they have on our app's performance.
Let's jump in!
What we're building
To explore this topic, we'll build on top of an existing GraphQL app called: Airlock.
Airlock is an intergalactic trip booking app: a resource we can use to find a cool place to stay in the wide open universe! We built the basics of this GraphQL server in the Intro to GraphQL course.
But don't worryβyou don't need to have completed the first course before starting! We'll give you a fresh repo to clone, and walk you through all the steps to get data loaders up and running.
Let's get everything ready to start building!
Project setup
To follow along with the course, you will need the following:
Prerequisite knowledge
We assume that you are familiar with GraphQL concepts like types, queries, and mutations. Check out our Intro to GraphQL with Java & DGS course if you need a refresher. In this course, we're using the Domain Graph Service (DGS) framework. DGS was created by the Netflix team and it enables GraphQL in a Spring Boot application with the addition of just a few dependencies.
You should also feel comfortable with Java programming concepts, (this course uses JDK 17) and the basics of Spring Boot.
Code editor or IDE
We're using IntelliJ IDEA (Community Edition).
Many popular IDEs offer plugins that enable GraphQL syntax highlighting. For IntelliJ, we recommend the GraphQL plugin.
Clone the repository
This course picks up where Intro to GraphQL with Java & DGS left off, but completing it first isn't a prerequisite! To start fresh, run the following command.
git clone https://github.com/apollographql-education/odyssey-dataloaders-dgs.git
Running the app
Finally, let's get our server up and running.
Open the odyssey-dataloaders-dgs
directory in your IDE and navigate to the main ListingApplication
file located in the com.example.listings
package. This is the starting point for our app.
@SpringBootApplicationpublic class ListingApplication {public static void main(String[] args) {SpringApplication.run(ListingApplication.class, args);}}
In IntelliJ, we can click the handy green play button in the margin next to the main
function, or the one located at the top of the interface.
Alternatively, you can open a new terminal to the root of your project and run the following command:
./gradlew bootRun
In the IDE Run output, we should see that our app is running!
> Task :ListingApplication.main(). ____ _ __ _ _/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/ ___)| |_)| | | | | || (_| | ) ) ) )' |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot :: (v3.2.0)
Up next
Let's get into data loaders, the problem they solve, and how we bring them into our application.
Share your questions and comments about this lesson
This course is currently in
You'll need a GitHub account to post below. Don't have one? Post in our Odyssey forum instead.