graphql-spring-webclient

GraphQL Spring Web client

License

License

GPL-3.0
Categories

Categories

Java Languages Spring Boot Container Microservices CLI User Interface Auto Application Layer Libs Code Generators config Configuration
GroupId

GroupId

com.graphql-java-kickstart
ArtifactId

ArtifactId

graphql-webclient-spring-boot-autoconfigure
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

graphql-spring-webclient
GraphQL Spring Web client
Project URL

Project URL

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

Source Code Management

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

Download graphql-webclient-spring-boot-autoconfigure

How to add to project

<!-- https://jarcasting.com/artifacts/com.graphql-java-kickstart/graphql-webclient-spring-boot-autoconfigure/ -->
<dependency>
    <groupId>com.graphql-java-kickstart</groupId>
    <artifactId>graphql-webclient-spring-boot-autoconfigure</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.graphql-java-kickstart/graphql-webclient-spring-boot-autoconfigure/
implementation 'com.graphql-java-kickstart:graphql-webclient-spring-boot-autoconfigure:1.0.0'
// https://jarcasting.com/artifacts/com.graphql-java-kickstart/graphql-webclient-spring-boot-autoconfigure/
implementation ("com.graphql-java-kickstart:graphql-webclient-spring-boot-autoconfigure:1.0.0")
'com.graphql-java-kickstart:graphql-webclient-spring-boot-autoconfigure:jar:1.0.0'
<dependency org="com.graphql-java-kickstart" name="graphql-webclient-spring-boot-autoconfigure" rev="1.0.0">
  <artifact name="graphql-webclient-spring-boot-autoconfigure" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.graphql-java-kickstart', module='graphql-webclient-spring-boot-autoconfigure', version='1.0.0')
)
libraryDependencies += "com.graphql-java-kickstart" % "graphql-webclient-spring-boot-autoconfigure" % "1.0.0"
[com.graphql-java-kickstart/graphql-webclient-spring-boot-autoconfigure "1.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
com.graphql-java-kickstart : graphql-webclient jar 1.0.0

runtime (3)

Group / Artifact Type Version
org.springframework.boot : spring-boot-autoconfigure jar 2.3.6.RELEASE
org.springframework.boot : spring-boot-starter-webflux jar 2.3.6.RELEASE
org.springframework.security : spring-security-oauth2-client jar 5.3.5.RELEASE

Project Modules

There are no modules declared in this project.

GraphQL Spring Webclient

Maven Central Publish snapshot Quality Gate Status

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
com.graphql-java-kickstart

GraphQL Java Kickstart

Provide libraries for using GraphQL Java. Some of these libraries used to be part of GraphQL Java itself, but have been extracted.

Versions

Version
1.0.0
0.3.0
0.2.0
0.1.2
0.1.0