Easy build API using Laravel and GraphQL (Mutation) part 2

Mutation GraphQL

Ardani Rohman
Aug 9, 2017 · 3 min read

Previous article we learn Building API using Laravel And GraphQL for Product List and User List, if you read previous article , i suggest you read it first. Now we will learn about Mutation and Authentication API with GraphQL

GraphQL is awesome technology for making simple and dynamic API, it is powerful for client app which develop using React Native / ReactJs. there are many library for support GraphQL documented in below

Mutation is type for inserting data into a database or altering data already in a database more detail here, in previous article we already have User Model, this sample we will add new user with profile and update user information using mutation query. First we must add new class for new user and update user

in NewUserMutation.php we have args function to declare field input and type input. Type::nonNull mean the field is required, in GraphQL query marked by exclamation (!), after save success we will return data user

UpdateUserMutation.php is example update data user, all action update and insert still using Eloquent and you can using Query builder for complicated query

you can find graphql.php in config folder and append class with namespace in mutation schema

add mutation class in GraphQL config

after append mutation class, open in documentation appears mutation detail

demo mutation GraphQL

don’t worry about full source code, you can access it below :). The next article we will continue learn GraphQL JWT Authentication

Click ❤ and follow me to get other articles. thanks

related articles

  1. Visual Studio Code Environment For Laravel
  2. Easy Build API Using Laravel And GraphQL (Query) part 1
  3. Easy Build API Using Laravel And GraphQL (Authentication) part 3


We help scale up your startup to the next level

Ardani Rohman

Written by

Remote Software Engineer at Agency Analytics. Ready for collaboration 🎯 find me: http://ardani.github.io


We help scale up your startup to the next level

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade