graphql - Postgraphile error while trying to open UI
问题描述
When I try to open postgraphile UI it's not working. I'm getting the following error.
A serious error occurred when building the initial schema. Exiting because
retryOnInitFail
is not set.Error: Connection terminated unexpectedly
at Connection. (D:\cars-assignment\node_modules\pg\lib\client.js:132:73)
at Object.onceWrapper (events.js:421:28)
at Connection.emit (events.js:315:20)
at Socket. (D:\cars-assignment\node_modules\pg\lib\connection.js:108:12)
at Socket.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1201:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
I'm using the following command
npx postgraphile -c postgres://username:SECRET@localhost:5000/db
How to resolve this issue?
解决方案
我认为错误输出比@deluxan 显示的更多。至少对我来说有。我认为问题在于 postgraphile 忽略了连接字符串中指定的端口。首先,我在端口 5555 上公开的 Docker 容器中运行 PostgreSQL。
17502bafdf52 exspda_postgis "docker-entrypoint.s…" 2 months ago Up 5 minutes 0.0.0.0:5555->5432/tcp exspda_postgis
然后当我尝试通过 Docker 运行 Postgraphile 时......
$ docker run --init -p 5000:5000 graphile/postgraphile --connection postgres://hippo:mypassword@localhost:5555/first_geo --schema public --watch
...完整的输出是:
PostGraphile v4.12.1 server listening on port 5000
‣ GraphQL API: http://0.0.0.0:5000/graphql
‣ GraphiQL GUI/IDE: http://0.0.0.0:5000/graphiql (RECOMMENDATION: add '--enhance-graphiql')
‣ Postgres connection: postgres://hippo:[SECRET]@localhost/first_geo (watching)
‣ Postgres schema(s): public
‣ Documentation: https://graphile.org/postgraphile/introduction/
‣ Node.js version: v12.22.1 on linux x64
‣ Join Storyscript in supporting PostGraphile development: https://graphile.org/sponsor/
* * *
A serious error occurred when building the initial schema. Exiting because `retryOnInitFail` is not set. Error details:
Error: connect ECONNREFUSED 127.0.0.1:5432
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16)
输出Postgres connection: postgres://hippo:[SECRET]@localhost/first_geo
不包括我在连接字符串中指定的端口。实际错误似乎也表明我指定的端口未使用:Error: connect ECONNREFUSED 127.0.0.1:5432
. 当我指定 5555 时,它正在尝试使用端口 5432。我怀疑这与@deluxan 经历的相同。端口 5432 是否在 postgraphile 中硬编码?如何修复识别用户提供的连接字符串中指定的端口?
请注意,我是 Postgraphile 的新手,所以我为愚蠢的(即对其他人来说显而易见的)疏忽和错误道歉!
推荐阅读
- swift - 如何在存储为字符串的 coredata 中对工作日进行排序
- pyspark - 将类似字符串的 XML 转换为 PySpark 数据框
- android - 多个 ReactContextBaseJavaModule
- javascript - 如何在嵌套对象数组中找到索引?
- rust - 在 rust 中的两个异步函数之间进行选择的变量 - 不兼容的 arm 类型
- python - Python - 多行到唯一行和转置列
- django - Django DetailView:将我切换到其他用户
- google-sheets - 如何在Google表格中对一个范围内的公式求和
- php - 在php中将多个文本字段写入现有的pdf文档
- javascript - TypeError:无法在回调中读取未定义的属性(读取“dataResponse”)