9. Follow-along: Using @defer1m

Using @defer

The router has this built-in capability to handle fields in a query that resolve more slowly than the rest. Using the @defer directive, we can specify which fields to defer.

To be deferred, a field needs to meet one of the following requirements:

  • It’s a root field of the Query type
  • It’s a field of any entity type

Follow-along: Adding @defer to our query

query HomepageWithFeatured {
... @defer {
featuredLocation {
id
name
photo
}
}
locations {
id
name
description
photo
}
}
Task!
Previous
Next

Share your questions and comments about this lesson

Your feedback helps us improve! If you're stuck or confused, let us know and we'll help you out. Note that all comments are public and must follow the Apollo Code of Conduct. You'll need a GitHub account to post below. Don't have one? Post in our Odyssey forum.