GraphQL allows the definition of methods in schema. All GraphQL API calls are POST in nature. The Spring Boot GraphQL Operations allows three types of Operation.
| GraphQL Operations | Rest API |
|---|---|
| Query | Equivalent to a GET call in Rest API |
| Mutation | Equivalent to POST and PUT in Rest API |
| Subscription | Equivalent to WebSocket in Rest API |
To support Query, Mutation, and Subscription, GraphQL needs to connect to the respective endpoint and load each field with its data, the DataFetchers is the underlying concept that connects the schema to the data. At some places DataFetchers also called as Resolvers.
Spring Boot provides an annotation-based approach to define the DataFetchers and hide the underlying boilerplate code and complexity. Spring boot supports four types of schema mapping ie @SchemaMapping, @QueryMapping, @MutationMapping, and @SubscriptionMapping.
| Annotation | Description |
|---|---|
| SchemaMapping | The SchemaMapping annotation is the parent of all DataFeachers annotation and workers with all types of operations |
| QueryMapping | The QueryMapping annotation can be used to denote the query operations |
| MutationMapping | The MutationMapping annotation is used to Update, Edit, and Delete operations |
| SubscriptionMapping | The SubscriptionMapping annotation is used to retrieve the web socket response for long-running data. |
Let's see all of them.