我在我的服务器中创建了postgraphile路由,在我的 app.ts 中有这一行:
app.use(postgraphileRoute)
现在,我想在我的存储库中访问这个路由。我正在使用graphql-request包,但我不知道我发送哪个 url 我new GraphQLClient()
尝试发送 serverURL/graphql(我从客户端访问它的方式)但它不起作用。我需要发送哪个网址?
问问题
47 次
1 回答
0
路由默认为,/graphql
但您可以使用该graphqlRoute
属性对其进行配置。另请参阅文档。
const express = require("express");
const { postgraphile } = require("postgraphile");
const app = express();
const postgraphileRoute = postgraphile(
process.env.DATABASE_URL || "postgres://user:pass@host:5432/dbname",
"public",
{
watchPg: true,
graphiql: true,
enhanceGraphiql: true,
graphqlRoute: '/graphql' // Set to any route you like
}
);
app.use(postgraphileRoute);
app.listen(process.env.PORT || 3000);
于 2020-07-20T16:03:52.747 回答