GraphQL Mutations - Learn Integrations on the Now Platform
[Music] so far in this series we've looked at ways to retrieve information from a server using a graphql query in this video we'll update our API so that where requesting data is created or updated using a mutation let's begin with the graphql API schema within the schema block we find a line that says mutation colon mutation by default if it's not there go ahead and add it this tells the schema that we're going to be using mutations next we'll create a type mutation block if it doesn't already exist like the type query block We'll add our functions in this case we'll create one named update case we'll provide some inputs like a mandatory ID optional State and comments and it returns an optional case object object since the case type is already defined we don't need to do any further modifications to the schema so we'll save and create a new resolver named update case the script first gets the value of the ID State and comments then it retrieves the case record and if the state or comments are set it applies those to the record and doesn't update we'll submit that and of course the resolver doesn't do any good without a resolver mapping so we'll go to the related list and create a new record mapping our mutation goon update case to the resolver update case and submit now let's navigate to The Misty Mountain app and open case 13 looks like bomber has a Leaky Barrel we'll test our mutation with a query like this and add variable values indicating that a new Barrel has been ordered and when we run the query and go back to the case record we see the comments have been updated mutations are pretty simple to construct and a great way to create or update records on the system as part of your graphql API
https://www.youtube.com/watch?v=LjGBBRpUnZ8