8 Implementing mutations

 

This chapter covers

  • Implementing GraphQL’s mutation fields
  • Authenticating users for mutation and query operations
  • Creating custom, user-friendly error messages
  • Using powerful database features to optimize mutations

We implemented most of the query tree for the AZdev GraphQL API in chapter 7. It’s now time to implement the mutation operations we planned, starting with the userCreate mutation to enable AZdev users to create an account and use other mutations (and queries) that require authenticated requests.

Since this is the very first mutation we’re creating, we need to do some groundwork to wire things up for all mutations. We basically need to make the schema ready to host mutations.

8.1 The mutators context object

8.2 The Mutation type

8.3 User mutations

8.3.1 The userCreate mutation

8.3.2 The userLogin mutation

8.4 Authenticating API consumers

8.4.1 The me root query field

8.5 Mutations for the Task model

8.6 Mutations for the Approach model

8.6.1 The approachCreate mutation

8.6.2 The approachVote mutation

8.7 The userDelete mutation

Summary