简体   繁体   English

如何在springboot graphql应用程序中设置基本URL

[英]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": "/"
}
  1. Q1 what should be the path to the server i should be using to invoke it. Q1应该是我用来调用它的服务器路径。
  2. Q2 is there a way to provide a custom base path something loke http://localhost:8080/service/api/query Q2有一种方法可以提供自定义基本路径,例如http:// localhost:8080 / service / api / query
  1. 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端点上运行查询。

  2. 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM