0
GraphQL服务实现
source link: https://perkins4j2.github.io/posts/522360011/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
GraphQL服务实现
GraphQL是一种用于API或数据的查询语言。
- 发出一个GraphQL请求就能准确获得想要的数据,不多不少。 - GraphQL查询总是返回可预测的结果。
- REST API请求多个资源时,GraphQL可以通过一次请求就获取所需的所有数据。
- GraphQL基于类型和字段的方式进行查询语言定义。
Maven引入
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
<version>15.0</version>
</dependency>
Schema定义
schema { |
GraphQL实例化
@Component |
@PublicApi |
支持Map
public static final GraphQLScalarType GraphQLMap = new GraphQLScalarType("Map", "A custom map scalar type", new Coercing() { |
扩展类型定义
scalar Short |
GraphQL调用
@Service |
DataFetcher定义
public DataFetcher find(ILoader loader, String idName){ |
------ 本文结束------
本文标题:GraphQL服务实现
文章作者:Perkins
发布时间:2020年09月01日
原始链接:https://perkins4j2.github.io/posts/522360011/
许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK