Créez votre première API GraphQL en 5 minutes avec Spring Boot GraphQL Auto-Generator
<dependency>
<groupId>com.enokdev</groupId>
<artifactId>graphql-autogen-spring-boot-starter</artifactId>
<version>1.0.1</version>
</dependency>
import com.enokdev.graphql.autogen.annotation.GraphQLType;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
@Entity
@GraphQLType // C'est tout ce dont vous avez besoin !
public class Product {
@Id @GeneratedValue
private Long id;
private String name;
private String description;
private Double price;
// Getters et setters
}
import org.springframework.data.jpa.repository.JpaRepository;
public interface ProductRepository extends JpaRepository {
// C'est tout !
}
C'est tout ! Lancez votre application Spring Boot, et votre API GraphQL est prête :
http://localhost:8080/graphiql