Interview questions
Question 231 of 254
FreeHow do you set up a GraphQL API in Spring Boot using spring-graphql?
GraphQL with Spring Boot
Add the `spring-boot-starter-graphql` dependency, define your API's schema in a `.graphqls` file under `src/main/resources/graphql/` (a schema-first approach — types, queries, and mutations are declared explicitly before any Java code), and implement resolver methods annotated `@QueryMapping`/`@MutationMapping`/`@SchemaMapping` in a `@Controller`-annotated class, matching the operations declared in the schema.
Intermediate5 min
