-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should I expect to see a single query when I enter a route, or possibly multiple? #176
Comments
It's the responsibility of the network layer to translate queries into network requests. The default network layer emits each query as a separate HTTP request, but that's the baseline behavior of the default one. For a real application, you should definitely use a network layer and a corresponding server that support batching multiple queries into a single HTTP request. For example, I'm currently using graphql/express-graphql#100 (on npm as I believe the most popular open-source batching network layer is @nodkz's https://github.com/nodkz/react-relay-network-layer – consider using that if you don't need the context-related semantics that I have. |
But also, no, RRR takes your queries and combines them into a single query config/Relay route. It doesn't otherwise touch your queries themselves. |
Thanks for the info! |
Issue #9 about how to use DataLoader with https://github.com/nodkz/react-relay-network-layer Example of how you can use a single DataLoader for all (batched) queries within a one HTTP-request in RRNL https://github.com/nodkz/react-relay-network-layer/blob/master/examples/dataLoaderPerBatchRequest.js |
I've just started to actually investigate and look into the efficiency of my GraphQL code and Relay queries. I am implementing DataLoader but noticed that some of my database query functions were being executed multiple times despite being DataLoader batch functions (I only expect to see them executed once). So I tabbed over to Chrome and can see that the React dev tools shows that Relay is making 3 separate queries for this single react router route. These 3 queries explains my DataLoader issue, but leads me to a new question: I thought a single route would be condensed into a single Relay query, is that true?
I'm using react router relay and react router dynamic routes. I'd post my route tree, but since I'm not using JSX routes that's not very simple to share my routes.
It's my understanding that react router relay takes care of building the graphql query for a particular route's component tree. If I hit a single route, should I expect to see 1 relay query? I'm currently seeing 3.
The text was updated successfully, but these errors were encountered: