0

When our project was based in REST, there was a response time of 200 ms ~ When changed the project be in GraphQL.

Because of each node trying to resolve, and after the resolve, their sub-entity is resolving too. cause to a extremely high latency, the response time is - 11 seconds !

What I did, is trying to pull ALL the information needed, including all the sub entities, and resolve this huge object from the query resolver.

the response time reduced to 800ms.

BUT, The resolver of the sub entities are still happening ! (I had to shut them for this test). How can I shut them off in some cases?

is there any other way to solve this?

Tal Gvili
  • 299
  • 1
  • 4
  • 15

1 Answers1

0

It sounds like maybe you want to fetch the associated data for each field only if the property on the parent object is undefined. So, if you resolver looks like this:

foos ({ id }, args, context) {
  return getFoos(id)
}

just make the call that fetches your data conditional, like this:

foos ({ id, foos }, args, context) {
  return foos ? foos : getFoos(id)
}
Daniel Rearden
  • 80,636
  • 11
  • 185
  • 183