Apollo GraphQL:为HTTPBatchedNetworkInterface设置端口?

时间:2017-09-07 18:39:36

标签: graphql apollo apollo-server apollostack

我正在尝试通过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的正确方法是什么?

提前致谢所有信息。

1 个答案:

答案 0 :(得分:0)

固定。我的框架是Meteor,我必须设置ROOT_URL = 10.0.1.10:3000/