Advanced GraphQL, v2

Errors & Testing Exercise

Scott Moss

Scott Moss

Superfilter AI
Advanced GraphQL, v2

Check out a free preview of the full Advanced GraphQL, v2 course

The "Errors & Testing Exercise" Lesson is part of the full, Advanced GraphQL, v2 course featured in this preview video. Here's what you'd learn in this lesson:

The students are instructed to use Apollo error classes to handle errors and to create integration tests for queries and mutations.


Transcript from the "Errors & Testing Exercise" Lesson

>> Use Apollo error classes to handle errors. So every where where we're throwing errors, like this authentication helpers and authorization helpers you created earlier on. Or anywhere else you're throwing errors, use the built in Apollo error classes instead. So slap those out, and then I need you to create some integration tests for your queries and mutations.

Just try to create one for a query. Try to create one more for mutation and that should be fine. Don't have to worry about all of them. I mean, you fill in like you really want to write some tests. Go ahead and test them all out. But one for query and one for mutation just so you can get a feel of it should be good.

And then I would say also just, I know resolvers seem pretty trivial, but also create a test for your resolver. So I don't have an example of that because it's pretty much the exact same thing as this. You will just need a test block or test just doesn't matter which one you use, and then you might do something like instead of snapshotting.

You might do something results from a resolver to equal something else and that's kinda how Matchers work in this, just so pretty simple. You just you don't need snapshots for that. So just just pick a resolver that you want maybe two or three, they should be pretty simple to get those going.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now