[英]How to set a base url in a springboot graphql app
How can we set a base url in springboot graphql-server app . 我们如何在springboot graphql-server app中设置基本URL。 By default the graphiql
api-console opens on http://localhost:8080/graphiql 默认情况下, graphiql
api-console在http:// localhost:8080 / graphiql上打开
Trying to access http://localhost:8080 through postman with a post -query as below : 尝试通过postman通过postman访问http:// localhost:8080 ,如下所示:
{
bookings {
name
}
}
gives an error saying : 给出错误信息:
{
"timestamp": 1549913598497,
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/"
}
Usually the server path for graphql endpoints is at http://localhost:8080/graphql
. 通常,graphql端点的服务器路径位于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. 在GraphiQL界面上运行查询时,如果不只是检查浏览器上的“网络”选项卡,它将在api端点上运行查询。
In order to change the base path you would need to change application.properties
into something like: 为了更改基本路径,您需要将application.properties
更改为以下内容:
graphql.servlet.mapping: /service/api/query
graphiql.mapping: /graphiql
graphiql.endpoint: /service/api/query
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.