-
Notifications
You must be signed in to change notification settings - Fork 47
Description
I'm trying to implement DataLoader which batches together underlying database queries within a single request. I'm looking towards react-relay-network-layer to assist with the batching of GraphQL queries into a single HTTP request so that I can use a single DataLoader for all queries within that request.
I notice that graphqlBatchHTTPWrapper calls the graphqlHTTPMiddleware for each query. I need to make accessible to each graphqlHTTPMiddleware call the same instance of my loaders. How do you suggest that I go about this?
Prior to adding react-relay-network-layer, or any batching, just using the default relay network layer, I was simply instantiating my DataLoaders right within the express-graphql middleware function and passing them to the resolvers via rootValue. I can no longer do that there because that'll create new DataLoaders for each query. I need a single DataLoader per request.
Looking for your advice. Thanks!