我在经营两个独立的码头服务。一个用于我的GraphQL服务器,另一个是连接到本地Postgres数据库的prisma服务。我能够在http://localhost:4466中直接运行prisma部署并测试它。但是当我试图在http://localhost:8080中使用我的应用程序的http://localhost:8080服务器进行查询时,它会给出以下响应。
{
"data": null,
"errors": [
{
"message": "request to http://localhost:4466/ failed, reason: connect ECONNREFUSED 127.0.0.1:4466",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"feed"
]
}
]
}这是堆栈跟踪。
graphql-server_1 | [Network error]: FetchError: request to http://localhost:4466/ failed, reason: connect ECONNREFUSED 127.0.0.1:4466
graphql-server_1 | Error: request to http://localhost:4466/ failed, reason: connect ECONNREFUSED 127.0.0.1:4466
graphql-server_1 | at new CombinedError (/usr/src/app/node_modules/graphql-binding/node_modules/graphql-tools/dist/stitching/errors.js:83:28)
graphql-server_1 | at Object.checkResultAndHandleErrors (/usr/src/app/node_modules/graphql-binding/node_modules/graphql-tools/dist/stitching/errors.js:101:15)
graphql-server_1 | at CheckResultAndHandleErrors.transformResult (/usr/src/app/node_modules/graphql-binding/node_modules/graphql-tools/dist/transforms/CheckResultAndHandleErrors.js:10:25)
graphql-server_1 | at /usr/src/app/node_modules/graphql-binding/node_modules/graphql-tools/dist/transforms/transforms.js:19:54
graphql-server_1 | at Array.reduce (<anonymous>)
graphql-server_1 | at applyResultTransforms (/usr/src/app/node_modules/graphql-binding/node_modules/graphql-tools/dist/transforms/transforms.js:18:23)
graphql-server_1 | at /usr/src/app/node_modules/graphql-binding/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:82:50
graphql-server_1 | at step (/usr/src/app/node_modules/graphql-binding/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:32:23)
graphql-server_1 | at Object.next (/usr/src/app/node_modules/graphql-binding/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:13:53)
graphql-server_1 | at fulfilled (/usr/src/app/node_modules/graphql-binding/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:4:58)我就是这样创建绑定的
const server = new GraphQLServer({
typeDefs: './src/schema.graphql',
resolvers,
context: req => ({
...req,
db: new Prisma({
typeDefs: './src/generated/prisma.graphql',
endpoint: 'http://localhost:4466',
secret: 'my-secret',
debug: true,
})
})
});我不知道问题出在哪里。
完整的代码可以在这里找到:https://github.com/dhanushuUzumaki/Journal/tree/feature/setup
发布于 2018-05-17 17:23:55
从prisma论坛那里得到了解决这个问题的帮助。
在容器中使用localhost指向容器本身,而不是运行容器的主机。因此,为了连接到Prisma实例,您必须使用内部服务名称,它解析为相应的Prisma容器。
...
db: new Prisma({
typeDefs: './src/generated/prisma.graphql',
endpoint: 'http://prisma:4466',
secret: 'my-secret',
debug: true,
})
...发布于 2018-09-21 13:03:29
这发生在我在windows上使用Docker时,必须将端点从使用本地主机更改为prisma.yml中的prisma.yml默认ip
endpoint: http://192.168.99.100:4466https://stackoverflow.com/questions/50377318
复制相似问题