graphql-go-tools
graphql-go-tools copied to clipboard
What is the BatchFactory struct's purpose?
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
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.
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)