18. Exercise: More error handling
1m

Instructions

Use what you learned in the Code-Along to add error handling to the incrementTrackLikes mutation.

  1. Set up a mutation in Sandbox that throws an error.

    mutation LikeTrack($trackId: ID!) {
    likeTrack(trackId: $trackId) {
    code
    success
    message
    track {
    id
    numberOfLikes
    }
    }
    }

    Variables:

    {
    "trackId": "this is not a real ID"
    }
  2. Add error handling to the resolver.

  3. Test in Sandbox that the same mutation now returns data instead of errors.

Solution

Previous
Next