分离 graphql/relay 后端和前端

Separate graphql/relay backend and frontend

我想使用中继将我的后端和前端与不同的项目分开。我这样做的原因是因为我正在使用特定的 relay/graphql 后端 sangria,并且希望将前端开发与 Scala 开发分开。

是否可以连接一台服务器上的 React 中继前端应用程序与另一台 graphql 服务器后端进行通信。中继似乎到处都假设它的端点与端点 /graphql

在同一台主机上

Relay's network layer 上的文档可能对您有用:

By default, Relay assumes that GraphQL is served at /graphql relative to the origin where our application is served. This can be re-configured by injecting a custom instantiation of the default network layer.

Relay.injectNetworkLayer(
    new Relay.DefaultNetworkLayer('http://example.com/graphql')
);

确保您的 graphql 服务器允许 cross-domain 使用 CORS headers 的请求。