From the course: Spring with GraphQL
Unlock the full course today
Join today to access over 24,200 courses taught by industry experts.
Creating the GraphQL controller - Spring Tutorial
From the course: Spring with GraphQL
Creating the GraphQL controller
- [Instructor] So now it's time to give GraphQL some actual exposure. We're going to build the controller so we can now wire it to the data and expose it to the GraphQL playground. So back in your IDE, go to source, main, Java, in the base package I want you to create a new package and we'll call this controller. Now in here we will create a new Java class called CustomerController. So the first thing that we're going to do is we're going to annotate this with @Controller. This will allow Spring Boot to load this automatically, so the definitions we're providing is all we're going to actually have to do to get GraphQL up and running. We need to have an instance in here of our customer repository and because we are going to do injection properly as a constructor parameter, we will add it to a constructor. There is no need to auto wire this, this is the only constructor now on this class, it will automatically get called…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Setting up the project4m 18s
-
(Locked)
Creating the schema4m 5s
-
(Locked)
Creating a Spring Data repository5m 41s
-
(Locked)
Creating the GraphQL controller6m 44s
-
(Locked)
Mutations5m 32s
-
(Locked)
Errors4m 8s
-
(Locked)
Challenge: Extending the API1m 19s
-
(Locked)
Solution: Extending the API4m 4s
-
(Locked)
-