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

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…

Contents