Closed ravangen closed 1 week ago
Yes, that's exactly what merge
is for :+1: I'm open to supporting def prime
if you'd like to implement it. It could probably be implemented without creating the Hash, too:
def prime(new_k, new_v)
key = result_key_for(new_k)
@results[key] = new_v
end
Thanks, makes sense. Should have looked more closely.
I'm going to close the issue for now, since I have something working. But I'll keep this in mind for the future.
Is your feature request related to a problem? Please describe.
Provide an option to prime the dataloader's result cache with the provided key and value to avoid data being fetched needlessly.
Examples:
graphql/dataloader
Shopify/graphql-batch
Describe the solution you'd like
Mechanism to add a result into a
GraphQL::Dataloader::Source
instance.EDIT: Looking more closely, is that the purpose of
merge
? Perhaps an alias could be of benefit?Additional context
Exploring feature parity between graphql-batch and dataloader, testing the wheels 😄