Open danvega opened 2 weeks ago
Customizing ExampleMatcher
is a reasonable request. Introducing a strategy interface that creates ExampleMatcher
would be my initial approach. I'm not quite sure about the context that we should provide to the method. I think something along the lines for an initial cut:
interface ExampleMatcherProvider<T> {
ExampleMatcher getExampleMatcher(T probe, DataFetchingEnvironment environment);
}
Such a signature would provide the most meaningful context.
For auto-registration, I think a programming model to let repositories implement the interface through a default method would be neat:
@GraphQlRepository
public interface BookRepository extends JpaRepository<Book, Long>,
QueryByExampleExecutor<Book>, ExampleMatcherProvider<Book> {
default ExampleMatcher getExampleMatcher(Book probe, DataFetchingEnvironment environment) {
return …;
}
}
Alternatively, defining a @Bean ExampleMatcherProvider<Book>
and using ResolvableType
to correlate the strategy object could work too.
I have a GraphQLRepository that extends QueryByExampleExectutor
If I try to do a partial match on the book title no results come back. If I enter the full book title the results come back as expected.
I realize I can write a data fetcher for this but this:
But I would like a way to customize this so I can use a
StringMatcher.CONTAINING
and match on part of the book title.