quinscape / domainql

Annotation-based extensible GraphQL-schema generator supporting
Apache License 2.0
8 stars 3 forks source link

Batched resolvers for sql? #1

Open yueliangwen opened 5 years ago

yueliangwen commented 5 years ago

Is there any guidance on how to avoid the common "n+1" problem?

fforw commented 5 years ago

So far there's no general support for that in domainql. I am working mostly done with a generalized query tool for automaton that goes even beyond batched resolvers in that it will generate large joined-table selects for all -to-one relations and put them together with additional joined queries for -to-many relations very much like a batched resolver does. That solution is not general though, but built for the "InteractiveQuery" based queries / the JOOQ-to-js criteria API embedded within

fforw commented 5 years ago

The current way to go beyond the naive fetchers would be to creating a view doing a better, or to create a Java-defined POJO that contains the result of multiple queries. Starting with 0.2.0 you can also define relations based on database views and general POJOs (and use the FetcherContext feature to fetch things in one-go and provide them for subsequent naive fetchers to use)

yueliangwen commented 5 years ago

@fforw I will consider your suggestions, thanks.