https://kotlinlang.org logo
#graphql-kotlin
Title
# graphql-kotlin
e

Eamonn

11/30/2021, 3:35 PM
Hello experts. The graphql-kotlin project looks great to me, but one tiny point in the ktor example was unclear. In the dataloaders, the entities are searched for based on a set of ids
Book.search(ids.flatten())
, and the resulting list is then filtered for only those that match that same set of ids
allBooks.filter { idSet.contains(it.id) }
. Is that filter not superfluous? Thanks, Eamonn https://github.com/ExpediaGroup/graphql-kotlin/blob/master/examples/server/ktor-se[…]aphql/examples/server/ktor/schema/dataloaders/BookDataLoader.kt
s

Shane Myrick

11/30/2021, 8:22 PM
You are correct that all the ids have been filtered, but the DataLoader is actually a
List<Int>
for the ids mapped to a
List<Book>
so that is why we have the double filter there to group the ids by all books so we only have to call
books.search
once I suppose what we could actually do is map every id to call the
Books.search
function instead, but this is just a basic example
👍 1