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

Create a custom resolver on client

From the course: Learning Apollo

Start my 1-month free trial

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…

Contents