Apollo Notes
Resolver
Lazy query in graphql
Sometimes we are not interested in getting all values of a node, we can do some tricks to prevent loading extra contents or generating infinite circular structure. Below example the users have many books, and each book have one owner, which is a user again. How can we query the user without returning the books, or reuse the node resolver if we want to return the books?
Let's assume your database can query any user by his username, any book by bookId, both username and bookId are unique
1. Just get my own nickname without querying my books
This can be achieved by self
resolver return the User object without exploiting the books field, in user resolver, you can get back the user object and in case user require books, retrive the books using the user object. Same for the book resolver