4

I would like to separate my backend and my frontend with different projects using relay. The reason I'm doing this is because I'm using a particular relay/graphql backend, sangria and would like to keep the frontend development separate from the Scala development.

Would it be possible to connect a react relay frontend application on one server communicating to another graphql server backend. It seems everywhere that relay assume that its endpoint is on the same host with endpoint /graphql

Atol
  • 569
  • 4
  • 12

1 Answers1

5

The docs on Relay's network layer might be useful to you:

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')
);

Make sure that your graphql server allows cross-domain requests using CORS headers.

bigblind
  • 12,539
  • 14
  • 68
  • 123