Closed deep-c closed 7 years ago
@deep-c Hi, the problem of stale data
is because you are not creating new instances
of Dataloader
for each request.
The function GT.getModelLoaders()
returns instances of Dataloader, which they should be recreated for every request, otherwise they will be living forever.
To solve the problem use the following approach:
router.post('/graphql', graphqlKoa(request => ({
schema: GraphQLSchema,
context: {
loaders: GT.getModelLoaders(),
},
debug: true,
})))
@fenos Thanks so much! I completely skipped over that crucial detail. :)
Hi @fenos , I am not a 100% sure about this problem I am having but it may be because I am not doing something properly. Hopefully you can point me in the right direction.
The problem I am having is that I am getting stale data back after inserting a new document through a mutation and then attempting to query for it. Only after restarting the server do I receive these records i created earlier.
If i make a query though the graphiql interface (right after running the mutation) i can see the mutation result in the query (i.e new records show up).
I have created a mutation as follows:
createChannel is as follows:
This is how i have defined the server.
Thanks!