Querying with GraphQL

Lessons

1. Intro to GraphQL

4:42

2. Fetching data with queries

9:11

3. Improving Developer Experience

5:43

4. Query variables, handling loading and errors

6:53

5. Advanced queries

5:52

6. Updating data with mutations

13:59

7. Bonus: Q&A with Natalia Tepluhina

21:29

8. Manual cache updates and optimistic responses

12:41

9. Real-time updates with subscriptions

6:59

10. Setting up local state with Apollo Client

6:05

11. Modifying local state with Apollo Client

4:48

Updating data with mutations

So far in our example app, we have only been fetching data from our GraphQL API endpoint. In this lesson, we’ll learn how to modify data on our server using GraphQL.


In a REST API, we typically use GET requests to fetch something, and POST / PUT / PATCH / UPDATE requests to change data on the server.

In GraphQL, however, the distinction is a bit simpler:

  • We use query when we need to fetch data
  • We use mutation when we need to modify anything

Let’s explore how to edit a book’s information, and look at how this affects the Apollo cache and how the changes are reflected in our Vue app.


Getting familiar with the updateBook mutation