Skip to content

Commit 44b37f1

Browse files
committed
Add example to readme fix #9
1 parent bf55b66 commit 44b37f1

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ When using Maven:
1515
<dependency>
1616
<groupId>com.graphql-java-kickstart</groupId>
1717
<artifactId>graphql-webclient-spring-boot-starter</artifactId>
18-
<version>0.2.0</version>
18+
<version>0.3.0</version>
1919
</dependency>
2020
```
2121

2222
When using gradle:
2323
```groovy
24-
implementation "com.graphql-java-kickstart:graphql-webclient-spring-boot-starter:0.2.0"
24+
implementation "com.graphql-java-kickstart:graphql-webclient-spring-boot-starter:0.3.0"
2525
```
2626

2727
Configure at least the URL of the GraphQL API to consume:
@@ -31,6 +31,27 @@ graphql:
3131
url: https://graphql.github.com/graphql
3232
```
3333
34+
The starter creates a Spring bean of type `GraphQLWebClient` that you can use in your
35+
classes to send queries. A simplified example might look like this:
36+
37+
```java
38+
@Component
39+
class MyClass {
40+
41+
private final GraphQLWebClient graphQLWebClient;
42+
43+
MyClass(GraphQLWebClient graphQLWebClient) {
44+
this.graphQLWebClient = graphQLWebClient;
45+
}
46+
47+
void executeSomeQuery() {
48+
GraphQLRequest request = GraphQLRequest.builder().query("query { hello }").build();
49+
GraphQLResponse response = graphQLWebClient.post(request).block();
50+
String value = response.get("hello", String.class);
51+
}
52+
}
53+
```
54+
3455
### Using latest Snapshots
3556

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

0 commit comments

Comments
 (0)