如何在springboot graphql应用程序中设置基本URL [英] How to set a base url in a springboot graphql app
问题描述
我们如何在springboot graphql-server app中设置基本URL.默认情况下, graphiql
api控制台在 http://localhost:8080/graphiql
How can we set a base url in springboot graphql-server app .
By default the graphiql
api-console opens on http://localhost:8080/graphiql
尝试通过邮递员使用如下查询语句访问 http://localhost:8080 :
Trying to access http://localhost:8080 through postman with a post -query as below :
{
bookings {
name
}
}
出现错误:
{
"timestamp": 1549913598497,
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/"
}
- Q1应该是我用来调用它的服务器的路径.
- 第二季度有一种方法可以提供自定义基本路径,例如 http://localhost:8080/service/api/query
推荐答案
-
graphql端点的服务器路径通常位于
http://localhost:8080/graphql
.在GraphiQL界面上运行查询时,如果不只是检查浏览器上的网络"选项卡,它将在api端点上运行查询.
Usually the server path for graphql endpoints is at
http://localhost:8080/graphql
. If not just inspect the network tab on your browser when you run a query on your GraphiQL interface, it will run the query on the api endpoint.
要更改基本路径,您需要将 application.properties
更改为类似的内容:
In order to change the base path you would need to change application.properties
into something like:
graphql.servlet.mapping: /service/api/query
graphiql.mapping: /graphiql
graphiql.endpoint: /service/api/query
这篇关于如何在springboot graphql应用程序中设置基本URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!