apollo-server部署到heroku后,"收到状态代码400"。[英] "Received status code 400" after apollo-server deploy to heroku

本文是小编为大家收集整理的关于apollo-server部署到heroku后,"收到状态代码400"。的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

如果我运行localy npm start - 一切都很好

如果我运行git subtree push --prefix server heroku-server master - 构建成功!

我打开https://tmdb-apollo.herokuapp.com/ - "error": "Response not successful: Received status code 400"

如果我仍然进行查询或突变 - 它可以工作!魔法! (但是我没有自动完成,右侧的shema侧边栏总是在旋转)

github repo 在这里

我怀疑这与我的MongoDB连接设置有关

推荐答案

已经将近3天了,直到我找到了一个解决方案: 需要添加introspection: true

// Set up Apollo Server
const server = new ApolloServer({
  typeDefs,
  resolvers,
  dataSources,
  context,
  introspection: true,
})

本文地址:https://www.itbaoku.cn/post/1938070.html

问题描述

If I run localy npm start - everything is ok

If I run git subtree push --prefix server heroku-server master - Build succeeded!

When I open https://tmdb-apollo.herokuapp.com/ - "error": "Response not successful: Received status code 400"

If I still do a query or mutation - it works! magic! (but I do not have autocomplete and shema sidebar on the right is always spinning)

Github repo here

I suspect it has something to do with my MongoDB connection setup

推荐答案

It's been nearly 3 days till I found a solution: Need to add introspection: true

// Set up Apollo Server
const server = new ApolloServer({
  typeDefs,
  resolvers,
  dataSources,
  context,
  introspection: true,
})