• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

graphql-java-kickstart/graphql-spring-webclient: Reactive GraphQL client for con ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

graphql-java-kickstart/graphql-spring-webclient

开源软件地址(OpenSource Url):

https://github.com/graphql-java-kickstart/graphql-spring-webclient

开源编程语言(OpenSource Language):

Java 95.7%

开源软件介绍(OpenSource Introduction):

GraphQL Spring Webclient

Maven Central Publish snapshot Quality Gate Status GitHub contributors Discuss on GitHub

Reactive GraphQL client for consuming GraphQL APIs from a Spring Boot application. Provides OAuth2 authorization through configuration.

Getting started

Add the starter to your project.

When using Maven:

<dependency>
  <groupId>com.graphql-java-kickstart</groupId>
  <artifactId>graphql-webclient-spring-boot-starter</artifactId>
  <version>1.0.0</version>
</dependency>

When using gradle:

implementation "com.graphql-java-kickstart:graphql-webclient-spring-boot-starter:1.0.0"

Configure at least the URL of the GraphQL API to consume:

graphql:
  client:
    url: https://graphql.github.com/graphql

The starter creates a Spring bean of type GraphQLWebClient that you can use in your classes to send queries. A simplified example might look like this:

@Component
class MyClass {
  
  private final GraphQLWebClient graphQLWebClient;
  
  MyClass(GraphQLWebClient graphQLWebClient) {
    this.graphQLWebClient = graphQLWebClient;
  }
  
  String helloWorld() {
    GraphQLRequest request = GraphQLRequest.builder().query("query { hello }").build();
    GraphQLResponse response = graphQLWebClient.post(request).block();
    return response.get("hello", String.class);
  }
}

Using latest Snapshots

You can use the latest Snapshots by configuring the Snapshot repository, see https://www.graphql-java-kickstart.com/servlet/#using-the-latest-development-build.

Configuration

The following tables list the configurable properties of the GraphQL Spring Webclient and their default values. These properties are configured with the prefix graphql.client, e.g. the property listed in the table as url should be defined as graphql.client.url in your Spring Boot configuration files.

Property Description
url Full URL of the GraphQL API to connect to, e.g. https://graphql.github.com/graphql
oauth2.client-id OAuth2 client id
oauth2.client-secret OAuth2 client secret
oauth2.token-uri Token URI of the identity provider
oauth2.authorization-grant-type By default the grant type client_credentials is used

Max in memory size

In case you need to work with large responses you might run into the following error:

Exceeded limit on max bytes to buffer : 262144

In that case starting with version 0.1.2 you can use the default Spring Boot configuration property to configure the max in memory size to use:

spring.codec.max-in-memory-size=10MB



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap