Skip to content

Commit 6327ab2

Browse files
committed
test
1 parent 79aa7e6 commit 6327ab2

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

stargate-client-graphql/src/main/java/com/datastax/stargate/sdk/gql/ApiGraphQLClient.java

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,24 @@
3333
*/
3434
public class ApiGraphQLClient {
3535

36+
private static final String DB_ID = "<change_me>";
37+
private static final String DB_REGION = "<change_me>";
38+
private static final String DB_TOKEN = "<change_me>";
39+
40+
3641
private static final String URL = "https://"
37-
+ "3ed83de7-d97f-4fb6-bf9f-82e9f7eafa23-"
38-
+ "eu-west-1"
39-
+ ".apps.astra.datastax.com/api/"
40-
+ "graphql-schema";
41-
private static final String TOKEN =
42-
"AstraCS:gdZaqzmFZszaBTOlLgeecuPs:edd25600df1c01506f5388340f138f277cece2c93cb70f4b5fa386490daa5d44";
42+
+ DB_ID + "-" + DB_REGION
43+
+ ".apps.astra.datastax.com/api/graphql-schema";
4344

4445
public static <T> GraphQLResponseEntity<T> callGraphQLService(String query, Class<T> clazz)
4546
throws Exception {
46-
47-
GraphQLTemplate graphQLTemplate = new GraphQLTemplate();
48-
4947
Map<String, String > headers = new HashMap<>();
50-
headers.put("x-cassandra-token", TOKEN);
51-
52-
GraphQLRequestEntity requestEntity = GraphQLRequestEntity.Builder()
53-
.url(URL)
54-
.request(query)
55-
.headers(headers)
56-
.build();
57-
return graphQLTemplate.query(requestEntity, clazz);
48+
headers.put("x-cassandra-token", DB_TOKEN);
49+
return new GraphQLTemplate().query(GraphQLRequestEntity.Builder()
50+
.url(URL)
51+
.request(query)
52+
.headers(headers)
53+
.build(), clazz);
5854
}
5955

6056
/**
@@ -63,18 +59,18 @@ public static <T> GraphQLResponseEntity<T> callGraphQLService(String query, Clas
6359
public static void main(String[] args)
6460
throws Exception {
6561

66-
// Building a request (with DSG codegen)
62+
// List Keyspaces
6763
GraphQLQueryRequest graphQLQueryRequest =
6864
new GraphQLQueryRequest(
6965
new KeyspacesGraphQLQuery.Builder().build(),
7066
new KeyspacesProjectionRoot().name());
7167

72-
// Executing query (with American Express Nodes)
68+
// Executing query
7369
GraphQLResponseEntity<KeyspaceList> res = callGraphQLService(
7470
graphQLQueryRequest.serialize(),
7571
KeyspaceList.class);
7672

77-
System.out.println("Keyspaces");
73+
// Showing results
7874
res.getResponse().getKeyspaces().stream().forEach(ks -> {
7975
System.out.println(ks.getName());
8076
});

0 commit comments

Comments
 (0)