【发布时间】:2018-02-16 14:08:31
【问题描述】:
我正在尝试通过 IP 地址连接到本地开发环境。我收到一个错误,因为 HTTPBatchedNetworkInterface 显示:
_uri: "http://10.0.1.10/graphql"
...当它需要时:
"http://10.0.1.10:3000/graphql"
这是我的服务器端设置代码:
const localHostString = '10.0.1.10';
const METEOR_PORT = 3000;
const GRAPHQL_PORT = 4000;
const server = express();
server.use('*', cors({ origin: `http://${localHostString}:${METEOR_PORT}` }));
server.use('/graphql', bodyParser.json(), graphqlExpress({
schema,
context
}));
server.use('/graphiql', graphiqlExpress({
endpointURL: '/graphql',
subscriptionsEndpoint: `ws://${localHostString}:${GRAPHQL_PORT}/subscriptions`
}));
// Wrap the Express server
const ws = createServer(server);
ws.listen(GRAPHQL_PORT, () => {
console.log(`GraphQL Server is now running on http://${localHostString}:${GRAPHQL_PORT}`);
console.log(`GraphiQL available at http://${localHostString}:${GRAPHQL_PORT}/graphiql`);
// Set up the WebSocket for handling GraphQL subscriptions
new SubscriptionServer({
execute,
subscribe,
schema
}, {
server: ws,
path: '/subscriptions',
});
});
将端口号输入HTTPBatchedNetworkInterface._uri 的正确方法是什么?
提前感谢大家提供任何信息。
【问题讨论】:
标签: graphql apollo apollo-server apollostack