graphql-go-tools icon indicating copy to clipboard operation
graphql-go-tools copied to clipboard

What is the BatchFactory struct's purpose?

Open schmidtw opened this issue 3 years ago • 2 comments
trafficstars

I'm working on unit testing some of my code that interacts with the BatchFactory code. I reviewed the BatchFactory code and was a bit confused as to why it was it's own struct. The struct is empty & the one function simply calls the other. Is there more to why this is a struct?

https://github.com/wundergraph/graphql-go-tools/blob/e6e1a13e36eaf3a4e09a2bbd1eca3dfcb3d955d6/pkg/engine/datasource/graphql_datasource/batch.go#L38

schmidtw avatar Jul 25 '22 21:07 schmidtw

It's a struct which implements: https://github.com/wundergraph/graphql-go-tools/blob/9fe3016fb1a70badd51f67b6923c4389b42a62df/pkg/engine/resolve/resolve.go#L301

The idea is to allow datasources to enable batching by implementing this interface.

jensneuse avatar Jul 26 '22 05:07 jensneuse

Thanks, that makes sense. Would you accept a PR adding the documentation / compile time check for this?

// Ensure the BatchFactory implements the DataSourceBatchFactory.
var _ resolve.DataSourceBatchFactory = (*BatchFactory)(nil)

schmidtw avatar Jul 27 '22 18:07 schmidtw