From 5e993ab5688bff989c69fb707c56bf53cfca170f Mon Sep 17 00:00:00 2001 From: Phillip Kruger Date: Tue, 14 Sep 2021 16:25:39 +0200 Subject: [PATCH] Add GraphQL UI to test endpoints in OIDC Dev UI Signed-off-by: Phillip Kruger --- .../java/io/quarkus/deployment/Capability.java | 1 + .../keycloak/KeycloakDevConsoleProcessor.java | 9 ++++++--- .../main/resources/dev-templates/provider.html | 18 ++++++++++++++++-- extensions/smallrye-graphql/runtime/pom.xml | 5 +++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/Capability.java b/core/deployment/src/main/java/io/quarkus/deployment/Capability.java index ad466141e02ac..1537e97a0695a 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/Capability.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/Capability.java @@ -104,6 +104,7 @@ public interface Capability { String SMALLRYE_OPENTRACING = QUARKUS_PREFIX + "smallrye.opentracing"; String SMALLRYE_HEALTH = QUARKUS_PREFIX + "smallrye.health"; String SMALLRYE_OPENAPI = QUARKUS_PREFIX + "smallrye.openapi"; + String SMALLRYE_GRAPHQL = QUARKUS_PREFIX + "smallrye.graphql"; String SMALLRYE_FAULT_TOLERANCE = QUARKUS_PREFIX + "smallrye.faulttolerance"; String SPRING_WEB = QUARKUS_PREFIX + "spring.web"; diff --git a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevConsoleProcessor.java b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevConsoleProcessor.java index 0d87d345f67ad..101269dbfbb62 100644 --- a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevConsoleProcessor.java +++ b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevConsoleProcessor.java @@ -44,9 +44,12 @@ public void setConfigProperties(BuildProducer c new DevConsoleTemplateInfoBuildItem("authorizationUrl", realmUrl + "/protocol/openid-connect/auth")); console.produce(new DevConsoleTemplateInfoBuildItem("logoutUrl", realmUrl + "/protocol/openid-connect/logout")); console.produce(new DevConsoleTemplateInfoBuildItem("oidcGrantType", config.devservices.grant.type.getGrantType())); - console.produce(new DevConsoleTemplateInfoBuildItem("swaggerIsAvailable", - capabilities.isPresent(Capability.SMALLRYE_OPENAPI))); - + if (capabilities.isPresent(Capability.SMALLRYE_OPENAPI)) { + console.produce(new DevConsoleTemplateInfoBuildItem("swaggerIsAvailable", true)); + } + if (capabilities.isPresent(Capability.SMALLRYE_GRAPHQL)) { + console.produce(new DevConsoleTemplateInfoBuildItem("graphqlIsAvailable", true)); + } } } diff --git a/extensions/oidc/deployment/src/main/resources/dev-templates/provider.html b/extensions/oidc/deployment/src/main/resources/dev-templates/provider.html index a7d104edab60a..212a1447e86bb 100644 --- a/extensions/oidc/deployment/src/main/resources/dev-templates/provider.html +++ b/extensions/oidc/deployment/src/main/resources/dev-templates/provider.html @@ -136,7 +136,7 @@ } function navigateToSwaggerUi(){ - {#if info:swaggerIsAvailable} + {#if info:swaggerIsAvailable??} var url = "{config:http-path('quarkus.swagger-ui.path')}"; var authorizedValue = { @@ -163,6 +163,15 @@ {/if} } + function navigateToGraphQLUi(){ + {#if info:graphqlIsAvailable??} + var url = "{config:http-path('quarkus.smallrye-graphql.ui.root-path')}"; + var headerJson = '{"authorization": "Bearer ' + accessToken + '"}'; + url = url + '/?' + encodeURIComponent('headers') + '=' + encodeURIComponent(headerJson); + window.open(url, '_blank').focus(); + {/if} + } + function copyToClipboard(token, type){ var dummy = document.createElement("input"); document.body.appendChild(dummy); @@ -408,11 +417,16 @@
Decoded
Test your service
- {#if info:swaggerIsAvailable} + {#if info:swaggerIsAvailable??} Swagger UI {/if} + {#if info:graphqlIsAvailable??} + + GraphQL UI + + {/if}
diff --git a/extensions/smallrye-graphql/runtime/pom.xml b/extensions/smallrye-graphql/runtime/pom.xml index 75067910e3714..9866a9142f5d9 100644 --- a/extensions/smallrye-graphql/runtime/pom.xml +++ b/extensions/smallrye-graphql/runtime/pom.xml @@ -50,6 +50,11 @@ io.quarkus quarkus-bootstrap-maven-plugin + + + io.quarkus.smallrye.graphql + +