use of io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient in project quarkus-github-app by quarkiverse.
the class GitHubService method createInstallationGraphQLClient.
private DynamicGraphQLClient createInstallationGraphQLClient(Long installationId) throws IOException, ExecutionException, InterruptedException {
CachedInstallationToken installationToken = installationTokenCache.get(installationId);
DynamicGraphQLClient graphQLClient = DynamicGraphQLClientBuilder.newBuilder().url(gitHubAppRuntimeConfig.instanceEndpoint + "/graphql").header(AUTHORIZATION_HEADER, String.format(AUTHORIZATION_HEADER_BEARER, installationToken.getToken())).build();
// this call is probably - it's not documented - not counted in the rate limit
graphQLClient.executeSync("query {\n" + "rateLimit {\n" + " limit\n" + " cost\n" + " remaining\n" + " resetAt\n" + " }\n" + "}");
return graphQLClient;
}
use of io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient in project smallrye-graphql by smallrye.
the class DynamicClientSSLTest method clientAuthentication_correctKeystore.
/**
* Server requests client authentication.
*/
@Test
public void clientAuthentication_correctKeystore() throws Exception {
HttpServer server = tools.runServer("classpath:ssl/server.pkcs12.keystore", "serverkeystorepassword", "classpath:ssl/server.pkcs12.truststore", "servertruststorepassword");
try {
System.setProperty("myclient3/mp-graphql/keystore", "classpath:ssl/client.pkcs12.keystore");
System.setProperty("myclient3/mp-graphql/keystorePassword", "clientkeystorepassword");
System.setProperty("myclient3/mp-graphql/keystoreType", "PKCS12");
WebClientOptions options = new WebClientOptions();
// don't require server auth
options.setTrustAll(true);
DynamicGraphQLClient client = new VertxDynamicGraphQLClientBuilder().configKey("myclient3").options(options).url("https://127.0.0.1:" + server.actualPort()).build();
client.executeAsync("asd").await().atMost(Duration.ofSeconds(1));
client.close();
} finally {
server.close();
}
}
use of io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient in project smallrye-graphql by smallrye.
the class DynamicClientSSLTest method serverAuthentication_correctTruststore.
/**
* Client requests server authentication.
*/
@Test
public void serverAuthentication_correctTruststore() throws Exception {
HttpServer server = tools.runServer("classpath:ssl/server.pkcs12.keystore", "serverkeystorepassword", null, null);
try {
System.setProperty("myclient1/mp-graphql/truststore", "classpath:ssl/client.pkcs12.truststore");
System.setProperty("myclient1/mp-graphql/truststorePassword", "clienttruststorepassword");
System.setProperty("myclient1/mp-graphql/truststoreType", "PKCS12");
DynamicGraphQLClient client = DynamicGraphQLClientBuilder.newBuilder().configKey("myclient1").url("https://127.0.0.1:" + server.actualPort()).build();
client.executeAsync("asd").await().atMost(Duration.ofSeconds(1));
client.close();
} finally {
server.close();
}
}
use of io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient in project smallrye-graphql by smallrye.
the class RecordAsInputToDynamicClientTest method testSimpleRecord.
@Test
public void testSimpleRecord() throws Exception {
try (DynamicGraphQLClient client = new VertxDynamicGraphQLClientBuilder().url(testingURL.toString() + "graphql").build()) {
Response response = client.executeSync("query { simple {a b} }");
SimpleRecord result = response.getObject(SimpleRecord.class, "simple");
assertEquals("a", result.a());
assertEquals("b", result.b());
}
}
use of io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient in project quarkus-github-action by quarkiverse.
the class GitHubEvent method getDynamicGraphQLClient.
public DynamicGraphQLClient getDynamicGraphQLClient() {
if (inputs.getGitHubToken().isEmpty()) {
throw new IllegalStateException("No GitHub token provided, unable to initialize the GitHub GraphQL client");
}
DynamicGraphQLClient localGitHubGraphQLClient = this.gitHubGraphQLClient;
if (localGitHubGraphQLClient == null) {
synchronized (this) {
localGitHubGraphQLClient = this.gitHubGraphQLClient;
if (localGitHubGraphQLClient == null) {
try {
this.gitHubGraphQLClient = localGitHubGraphQLClient = DynamicGraphQLClientBuilder.newBuilder().url(context.getGithubGraphQLUrl()).header(AUTHORIZATION_HEADER, String.format(AUTHORIZATION_HEADER_BEARER, inputs.getGitHubToken().get())).build();
// this call is probably - it's not documented - not counted in the rate limit
localGitHubGraphQLClient.executeSync("query {\n" + "rateLimit {\n" + " limit\n" + " cost\n" + " remaining\n" + " resetAt\n" + " }\n" + "}");
} catch (Exception e) {
throw new IllegalStateException("Unable to initialize the GitHub GraphQL client, is the token valid?", e);
}
}
}
}
return localGitHubGraphQLClient;
}
Aggregations