Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zaibacu/java-graphql-client
A client library to access GraphQL APIs
https://github.com/zaibacu/java-graphql-client
client graphql graphql-client java
Last synced: about 2 months ago
JSON representation
A client library to access GraphQL APIs
- Host: GitHub
- URL: https://github.com/zaibacu/java-graphql-client
- Owner: zaibacu
- License: mit
- Created: 2020-07-31T13:44:18.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-11-17T20:55:03.000Z (about 2 years ago)
- Last Synced: 2024-10-13T06:05:40.239Z (3 months ago)
- Topics: client, graphql, graphql-client, java
- Language: Java
- Homepage:
- Size: 50.8 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Java GraphQL Client
Interact with GraphQL API via Java. Nothing more, nothing less.
# Quickstart
## Install
Maven:
```xmlcom.github.zaibacu
java-graphql-client
1.2-SNAPSHOT```
## Usage
### Query
```java
public class Example{
public List fetchProducts(){
GraphqlClient client = GraphqlClient
.builder()
.withUrl("http://localhost:8000/graphql")
.build();
List products = client
.query("products")
.withParameter("category", "shoes")
.withParameter("priceRange", "cheap")
.execute("products", Product.class);return products;
}
}
```Where `Product` is:
```java
public class Product implements Serializable{
public String name;
public double price;
public String category;
public String priceRange;
}
```### Mutation
```java
public class Example {
public void addProduct(Product product){
GraphqlClient client = GraphqlClient
.builder()
.withUrl("http://localhost:8000/graphql")
.build();
client
.mutate("addProduct")
.withParameter("name", "test")
.withParameter("price", 42.0)
.withParameter("category", "shoes")
.withParameter("priceRange", "cheap")
.execute("products");}
}
```