springboot 开发graphql接口,及接口调用

刘和玉
2023-12-01

graphql 入门介绍

https://blog.csdn.net/z69183787/article/details/86759767

引入springboot相应jar包,这里指指明使用的graphql相关jar包

<!-- graphql -->
<dependency>
    <groupId>com.graphql-java</groupId>
    <artifactId>graphql-spring-boot-starter</artifactId>
    <version>4.0.0</version>
</dependency>
<dependency>
    <groupId>com.graphql-java</groupId>
    <artifactId>graphql-java-tools</artifactId>
    <version>4.3.0</version>
</dependency>

1.定义查询语言

1)root.graphqls

type Query {
    findAllAuthors: [Author]!
    countAuthors: Long!
    findOneAuthor(id: Long!): Author
    findAllBooks: [Book]!
    countBooks: Long!
    findAuthorsByFilter(filter: [AuthorInput],first: Int): [Author]!
}

2)schema.graphql

 类似资料: