Skip to content

Commit

Permalink
mermaid diagram GraphQL client
Browse files Browse the repository at this point in the history
Signed-off-by: Andres LeonRangel <[email protected]>
  • Loading branch information
aleon1220 committed Sep 26, 2023
1 parent 5e5cd24 commit f346264
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- [Attendance WebApp UI](#attendance-webapp-ui)
- [Refer to the Wiki for details on the project](#refer-to-the-wiki-for-details-on-the-project)
- [Project general guidelines](#project-general-guidelines)
- [API/Services Architectures](#apiservices-architectures)
- [Extra mermaid diagram](#extra-mermaid-diagram)
- [Setup](#setup)
- [Build Web Package](#build-web-package)
- [Maven Build](#maven-build)
Expand Down Expand Up @@ -72,6 +74,28 @@ To find out more, visit:
3. Latest releases by using git tags
4. API references. API docs

## API/Services Architectures
```mermaid
graph LR
REST --> JSON
REST --> XML
REST --> Webhooks
REST --> gRPC
REST --> GraphQL
REST --> WebSockets
gRPC --> Protobuf
GraphQL --> Queries
GraphQL --> Mutations
WebSockets --> Full-duplex-communication
WebSockets --> Real-time-updates
Webhooks --> HTTP-callbacks
Webhooks --> Event-driven-architecture
```
## Extra mermaid diagram
circular references

[![](https://mermaid.ink/img/pako:eNptksEOgjAQRH-F7Fl-gIMXNV4wUTDx0kulKxCEklIOhvDvtmAoXeypfTOdySY7QCYFQgS54m0RxAlrAnOSU3oPwnAf5Mn1QNDZOm8xoQ98pjKrUHdboZCyMngWbOIkWAdBXvRCafRa8KJ_30n6mrpx1pQWEM3rcF5SQwTXRARvRqL9KZve2yqHvSKHaY1TXCfsoEZV81KYBRislYEusEYGkbkKrioGrBmNj_dapp8mg-jF3x3uoG8F13gsuVmceqEoSi3VZV6pabPGL4act8s?type=png)](https://mermaid.live/edit#pako:eNptksEOgjAQRH-F7Fl-gIMXNV4wUTDx0kulKxCEklIOhvDvtmAoXeypfTOdySY7QCYFQgS54m0RxAlrAnOSU3oPwnAf5Mn1QNDZOm8xoQ98pjKrUHdboZCyMngWbOIkWAdBXvRCafRa8KJ_30n6mrpx1pQWEM3rcF5SQwTXRARvRqL9KZve2yqHvSKHaY1TXCfsoEZV81KYBRislYEusEYGkbkKrioGrBmNj_dapp8mg-jF3x3uoG8F13gsuVmceqEoSi3VZV6pabPGL4act8s)

## Setup
> Tested in Win11 with WSL, Github codespaces and Ubuntu22
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/clients/GraphQL/GraphQLClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import com.graphql.java.client.GraphQLClient;
import com.graphql.java.client.GraphQLClientBuilder;
import com.graphql.java.client.GraphQLRequest;
import com.graphql.java.client.GraphQLResponse;

public class GraphQLClient {

private final GraphQLClient graphQLClient;

public GraphQLClientExample(String graphQLAPIEndpointURL) {
graphQLClient = GraphQLClientBuilder.newClient(graphQLAPIEndpointURL).build();
}

public GraphQLResponse executeQuery(String query) {
GraphQLRequest graphQLRequest = new GraphQLRequest(query);
return graphQLClient.execute(graphQLRequest);
}

public static void main(String[] args) {
GraphQLClientExample graphQLClientExample = new GraphQLClientExample("https://graphql.example.com");

// Execute a GraphQL query
GraphQLResponse graphQLResponse = graphQLClientExample.executeQuery("{ hello }");

// Parse the GraphQL response
String hello = graphQLResponse.getData().get("hello").toString();

// Print the result
System.out.println(hello);
}
}

0 comments on commit f346264

Please sign in to comment.