我们已经有一个包含数据的Postgresql数据库,并且我们正在尝试将postgraphile作为graphql API。我们遇到了一个错误,使我们挠头。服务器运行正常,但我们得到以下信息:
postgraphile -c postgres://username:password@localhost:5432/my_db
PostGraphile server listening on port 5000
‣ Connected to Postgres instance postgres://localhost:5432/my_db
‣ Introspected Postgres schema(s) public
‣ GraphQL endpoint served at http://localhost:5000/graphql
‣ GraphiQL endpoint served at http://localhost:5000/graphiql
* * *
An error occurred, it might be okay but it doesn't look like the error we were expecting... run with envvar 'DEBUG="graphile-build:warn"' to view the error
An error occurred, it might be okay but it doesn't look like the error we were expecting... run with envvar 'DEBUG="graphile-build:warn"' to view the error
Error: Query root type must be provided.
at assertValidSchema (C:\Users\user\AppData\Roaming\npm\node_modules\postgraphile\node_modules\graphql\type\validate.js:78:11)
at Object.validate (C:\Users\user\AppData\Roaming\npm\node_modules\postgraphile\node_modules\graphql\validation\validate.js:61:35)
at parseQuery (C:\Users\user\AppData\Roaming\npm\node_modules\postgraphile\build\postgraphile\http\createPostGraphileHttpRequestHandler.js:208:48)
at Promise.all.paramsList.map (C:\Users\user\AppData\Roaming\npm\node_modules\postgraphile\build\postgraphile\http\createPostGraphileHttpRequestHandler.js:469:63)
at Array.map (<anonymous>)
at requestHandler (C:\Users\user\AppData\Roaming\npm\node_modules\postgraphile\build\postgraphile\http\createPostGraphileHttpRequestHandler.js:435:52)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
,当我们导航到localhost:500 / graphiql时,在文档资源管理器中看到“无可用模式”。
查询是否以public
模式为根?还是我们想念什么?
答案 0 :(得分:0)
较新版本的PostGraphile具有更多有用的错误消息,通常包括建议的解决方案。像上面的那些“发生错误”错误现在也包含潜在错误的预览,有助于诊断。
此处有有关如何在此处设置<!DOCTYPE HTML>
<head>
<link rel="stylesheet" href="staffdesign.css">
<meta charset="UTF-8" />
</head>
<body>
<h3>Staff Page</h3>
<div class="staffboxes">
<p>
<div class="staffpfp"><img src="https://i.stack.imgur.com/f505l.png" alt="Kouhai's DP" /></div>
<h3>Kouhai</h3>
</p>
</div>
</body>
</html>
环境变量的说明:https://www.graphile.org/postgraphile/debugging/#debug-envvars
在Linux,macOS或Windows上,您可能会这样做:
DEBUG