Reputation: 73
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
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
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 RootContainer
s by creating a single container that comprises a Relay component with other non-Relay parts of the UI nested inside.
Upvotes: 1