From the course: Learning Apollo
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Create a custom resolver on client
- [Instructor] Okay so now we need to continue working on the app.js, and create what we call a custom resolver. So the purpose of that resolver will be to pass the contact ID to a route which will allow it to create a new page with that route and the component with the information inside of it. So let's go ahead and create the function that we'll use to basically return the ID. dataIdFromObject Okay so in this particular function that we're creating, we'll pass the result. And if the result is of a particular typename, then we'll do whatever comes next. So we'll check if the result.id is not undefined, then return the ID. So basically we're building up the URL that we need to use for the route with this particular function. So we'll do a template string that will return the result._typename and then return the result.id. So this function will create the URL from the results of the search. So for example, if we get a result, then they typename here, which will be contact, will be…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Introduction to subscriptions and schema9m 18s
-
(Locked)
Update resolvers for subscriptions10m 22s
-
(Locked)
Update components for subscriptions9m 6s
-
(Locked)
Create a custom resolver on client6m 2s
-
(Locked)
Add new contact header component5m 14s
-
(Locked)
Connect subscription with contact single14m 18s
-
(Locked)
Adding new notes with mutations15m 47s
-
(Locked)
Finalizing project with a beauty pass12m 13s
-
(Locked)
-