0

我们有一个现有的包含数据的 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模式吗?或者我们缺少什么?

4

1 回答 1

0

较新版本的 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_db
于 2018-09-10T17:48:01.677 回答