Fork me on GitHub
#graphql
<
2017-08-28
>
abarylko02:08:42

I'm writing my first schema and I'm wondering about the resolution of nested fields

abarylko02:08:59

for example { movies { name actors } } and I have a resolver for movies and one for actors ... but I was wondering if I need to know when I'm asking for only movies or for movies and actors to do a different query ....

abarylko02:08:07

also not sure when doing the actors resolver getting the id of the movie in order to run the query ...

hmaurer07:08:05

@abarylko usually no, you would not need to know if you are asking for movies or for movies and actors

hmaurer07:08:01

You can get that information if you need to (for performance reasons) bit that's well beyond what a beginner should care about

abarylko07:08:17

@hmaurer so how can I tell which actors I need to search for?

hmaurer08:08:20

@abarylko the graphql resolver should take as parameter the “movie” object

hmaurer08:08:23

so you can do a query based on that

hmaurer08:08:11

@abarylko are you using Lacinia?