Skip to content

Commit

Permalink
Remove configuration key for GraphQL schema path
Browse files Browse the repository at this point in the history
Currently, the GraphQL schema is exposed under /graphql/schema (so
relative to the main graphql endpoint) and is configurable with the
`spring.graphql.schema.printer.path` configuration property.

We think we should make the schema location more consistent to help
tools and various Gateway products. Also, we don't see right now a
strong use case for such a configuration property.

This commit removes the configuration property and sets the schema
location under `/graphql/schema`(`/graphql` being the main graphql path
configured by the application).

Closes gh-79
  • Loading branch information
bclozel committed Jul 2, 2021
1 parent 9a23e5f commit 2be79c2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ public static class Printer {
*/
private boolean enabled = false;

/**
* Path under the main GraphQL path where the schema is exposed.
*/
private String path = "/schema";

public boolean isEnabled() {
return this.enabled;
}
Expand All @@ -111,14 +106,6 @@ public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public String getPath() {
return this.path;
}

public void setPath(String path) {
this.path = path;
}

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.stream.Collectors;

import graphql.GraphQL;
import graphql.schema.idl.SchemaPrinter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Expand Down Expand Up @@ -115,8 +114,7 @@ public RouterFunction<ServerResponse> graphQlEndpoint(GraphQlHttpHandler handler

if (properties.getSchema().getPrinter().isEnabled()) {
SchemaHandler schemaHandler = new SchemaHandler(graphQlSource);
String schemaPath = properties.getSchema().getPrinter().getPath();
builder = builder.GET(graphQLPath + schemaPath, schemaHandler::handleRequest);
builder = builder.GET(graphQLPath + "/schema", schemaHandler::handleRequest);
}

return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ public RouterFunction<ServerResponse> graphQlRouterFunction(GraphQlHttpHandler h

if (properties.getSchema().getPrinter().isEnabled()) {
SchemaHandler schemaHandler = new SchemaHandler(graphQlSource);
String schemaPath = properties.getSchema().getPrinter().getPath();
builder = builder.GET(graphQLPath + schemaPath, schemaHandler::handleRequest);
builder = builder.GET(graphQLPath + "/schema", schemaHandler::handleRequest);
}

return builder.build();
Expand Down
3 changes: 2 additions & 1 deletion spring-graphql-docs/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ schema locations to check as follows:
spring.graphql.schema.locations=classpath:graphql/
----

The GraphQL schema can be viewed over HTTP at "/graphql/schema", if enabled:
The GraphQL schema can be viewed over HTTP at "/graphql/schema", relative to the main graphql endpoint path.
It is disabled by default:

[source,properties,indent=0,subs="verbatim,quotes"]
----
Expand Down

0 comments on commit 2be79c2

Please sign in to comment.