我们已经有了一个包含数据的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时,我们在文档资源管理器中看到一个"no schema available“。
查询根是public模式吗?或者我们错过了什么?
发布于 2018-09-11 01:48:02
较新版本的PostGraphile有更有用的错误消息,通常包括建议的解决方案。类似上述的“发生错误”错误现在还包含有助于诊断的潜在错误的预览。
这里有关于如何设置DEBUG环境变量的说明:https://www.graphile.org/postgraphile/debugging/#debug-envvars
下面是你在Linux、macOS或Windows中如何做到这一点:
# Bash (Linux, macOS, etc)
export DEBUG="graphile-build:warn" postgraphile -c postgres://username:password@localhost:5432/my_db
# Windows Console
set DEBUG=graphile-build:warn & postgraphile -c postgres://username:password@localhost:5432/my_db
# Windows PowerShell
$env:DEBUG = "graphile-build:warn"; postgraphile -c postgres://username:password@localhost:5432/my_dbhttps://stackoverflow.com/questions/51220312
复制相似问题