【问题标题】:Apollo GraphQL: Setting Port for HTTPBatchedNetworkInterface?Apollo GraphQL:为 HTTPBatchedNetworkInterface 设置端口?
【发布时间】: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


    【解决方案1】:

    已修复。我的框架是 Meteor,我必须设置ROOT_URL = 10.0.1.10:3000/

    【讨论】:

      猜你喜欢
      • 2021-12-04
      • 2019-06-13
      • 2020-01-04
      • 2017-01-11
      • 2022-12-14
      • 2019-06-22
      • 2021-01-11
      • 2020-06-12
      • 2019-09-27
      相关资源
      最近更新 更多