---
title: "Understanding GraphQL for Beginners–Part Three"
description: "Part Three of a beginner GraphQL series introduces mutations for creating, updating, and deleting database objects, extending the earlier focus on queries that fetch data. Using the existing Rails repository with Food and Nutrition ActiveRecord models, it shows how to generate mutation classes with rails g graphql:mutation and register root fields in mutation_type.rb. The tutorial defines input arguments, uses snake_case fields that GraphQL converts to camelCase, and implements a resolve method that creates or locates records and returns typed responses. It demonstrates foodCreate, foodUpdate, and foodDelete in GraphiQL, while exercises ask readers to build corresponding Nutrition mutations. It concludes that mutations use the same endpoint as queries and that each schema field has a resolve method that returns its response."
---

# Understanding GraphQL for Beginners–Part Three

[Shopify](https://yomu.fyi/company/shopify) · 2023-10-18 · Aug 6, 2021

**Type:** Tutorial

## Summary

Part Three of a beginner GraphQL series introduces mutations for creating, updating, and deleting database objects, extending the earlier focus on queries that fetch data. Using the existing Rails repository with Food and Nutrition ActiveRecord models, it shows how to generate mutation classes with rails g graphql:mutation and register root fields in mutation\_type.rb. The tutorial defines input arguments, uses snake\_case fields that GraphQL converts to camelCase, and implements a resolve method that creates or locates records and returns typed responses. It demonstrates foodCreate, foodUpdate, and foodDelete in GraphiQL, while exercises ask readers to build corresponding Nutrition mutations. It concludes that mutations use the same endpoint as queries and that each schema field has a resolve method that returns its response.

## Context

The tutorial builds on an earlier part that covered GraphQL queries for fetching data and addresses how to create, modify, and delete Food and Nutrition database records in the existing Rails repository.

## Approach / What changed

It uses Rails GraphQL mutation generators, mutation root fields, input arguments, typed responses, and resolve methods. Examples implement foodCreate, foodUpdate, and foodDelete, with GraphiQL used to test the mutations and exercises extending the work to Nutrition records.

## Takeaways

- GraphQL mutations create, modify, or delete database objects and are sent to the same endpoint as query requests.
- The Rails generator rails g graphql:mutation nameAction creates mutation scaffolding and adds the corresponding root field to mutation\_type.rb.
- Mutation resolve methods receive the input, perform the ActiveRecord operation, and return the response type declared by the mutation.

**Tags:** [GraphQL](https://yomu.fyi/topic/graphql)

- Source: [Shopify](https://shopify.engineering/understanding-graphql-for-beginners-part-three)
- Source URL: https://shopify.engineering/understanding-graphql-for-beginners-part-three
- Ingested by Yomu: 2026-08-30T15:29:35.497Z

[Read original post](https://shopify.engineering/understanding-graphql-for-beginners-part-three)
