jzalucki
jzalucki

Reputation: 73

Multiple entry points (routes) as single request with multiple queries?

I want to start using Relay in my application but it can be done only part by part. This means that I will end up with several applications embedded inside page each with its own entry point. This way every entry point will be creating its own graphql query and will send it as separate request which obviously is not what I want to achieve.

Is there any possibility to have multiple entry points that will be collected and send to server as one request with multiple root queries? If not maybe there is a workaround that can be applied? Any suggestions are welcome.

Upvotes: 1

Views: 960

Answers (2)

steveluscher
steveluscher

Reputation: 4228

From the ‘heinous hack’ department: you could create a custom network layer that batches up any calls to sendQueries(), sends them to the server in a single request, and resolves the promises with the correct part of the response.

See also: http://facebook.github.io/relay/docs/guides-network-layer.html#custom-network-layers

Upvotes: 0

Greg Hurrell
Greg Hurrell

Reputation: 5457

At the moment the Relay.RootContainer is the unit of abstraction for grouping components together and dealing with their collective data-fetching requirements as a single unit.

You can nest non-Relay components inside of Relay ones, so you may be able to avoid issuing multiple, independent requests from multiple RootContainers by creating a single container that comprises a Relay component with other non-Relay parts of the UI nested inside.

Upvotes: 1

Related Questions