Closed arthurvaverko closed 1 year ago
Nevermind :/ forgot about gorutines :/
@arthurvaverko what was your solution for this? I am seeing the same issue.
You have to call the load function concurrently otherwise it's regular code execution that waits until the batchFunc is resolved and only the makes another load call
For anyone wondering how to use this with graphql-go/graphql, you need to return a function in the resolver rather than the result of the thunk
function.
i.e. rather than this:
field.Resolve = func(p graphql.ResolveParams) (any, error) {
// ... do stuff ...
thunk := loader.Load(p.Context, fmt.Sprint(id))
return thunk()
}
do this:
field.Resolve = func(p graphql.ResolveParams) (any, error) {
// ... do stuff ...
thunk := loader.Load(p.Context, fmt.Sprint(id))
return func() (any, error) {
return thunk()
}, nil
}
Im using dataloader V7 with generic and i have a simple test func ..
this test output is
it removes the duplicate requets for id 200 but why i don't get the batched slice including all 3 ids ?