-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14278 from phillip-kruger/graphql-npe-no-endpoint
Create better response when no GraphQL endpoint has been generated
- Loading branch information
Showing
4 changed files
with
78 additions
and
19 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
...main/java/io/quarkus/smallrye/graphql/deployment/SmallRyeGraphQLInitializedBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.quarkus.smallrye.graphql.deployment; | ||
|
||
import io.quarkus.builder.item.SimpleBuildItem; | ||
import io.quarkus.runtime.RuntimeValue; | ||
|
||
final class SmallRyeGraphQLInitializedBuildItem extends SimpleBuildItem { | ||
|
||
private final RuntimeValue<Boolean> initialized; | ||
|
||
public SmallRyeGraphQLInitializedBuildItem(RuntimeValue<Boolean> initialized) { | ||
this.initialized = initialized; | ||
} | ||
|
||
public RuntimeValue<Boolean> getInitialized() { | ||
return initialized; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...e/src/main/java/io/quarkus/smallrye/graphql/runtime/SmallRyeGraphQLNoEndpointHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.quarkus.smallrye.graphql.runtime; | ||
|
||
import io.vertx.core.Handler; | ||
import io.vertx.core.http.HttpHeaders; | ||
import io.vertx.core.http.HttpServerResponse; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
/** | ||
* Handler that is used when no endpoint is available | ||
*/ | ||
public class SmallRyeGraphQLNoEndpointHandler implements Handler<RoutingContext> { | ||
private static final String CONTENT_TYPE = "text/plain; charset=UTF-8"; | ||
private static final String MESSAGE = "GraphQL Schema not generated. Make sure you have a GraphQL Endpoint. Go to https://quarkus.io/guides/microprofile-graphql to learn how"; | ||
|
||
@Override | ||
public void handle(RoutingContext event) { | ||
HttpServerResponse response = event.response(); | ||
response.headers().set(HttpHeaders.CONTENT_TYPE, CONTENT_TYPE); | ||
response.setStatusCode(404).end(MESSAGE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters