Question about the http4k-graphql module: I’m look...
# http4k
a
Question about the http4k-graphql module: I’m looking at the example that is given in the examples repo, and I’m testing the following query against `localhost:8000/graphql/user`:
Copy code
{
  search(params: {ids: [1,2]}){
    id
    name 
  }
  s2:search(params: {ids: [1,2]}){
    id
    name 
  }
}
and using a small
.also { println("running some expensive query") }
I was able to see that this was calling the
UserQueries.search
method twice. Since the example specifically has a dataloader, I was wondering why? Isn’t the whole point of dataloaders that regardless of how the query is formed, one only calls the underlying service just once? Or is this specific to nested queries only (i.e. calls to fields of type
User
say for instance a
friends
field that invokes some kind of function towards the DB)? What am I misunderstanding here?
d
TBH, the example is a very naive one used to show how to integrate the module. If it can be improved (whist also remaining clear) then we've love to know how!
a
I think what I’m struggling to understand is whether or not the dataloader is actually being used. It seems that it isn’t.
I used the following to verify (in the UserDbHandler class):
Copy code
UserQueries().search(Params(ids)).also { println("some expensive db function") }
It never prints that line
That to me suggests that the dataloader is not actually used by the graphql engine