Instructor: To change data with GraphQL, we use a mutation. These are named just like queries and the schema. Within the schema, we have a mutation called createAccount. Let's write that mutation.
We're going to use the mutation keyword. We're going to use the name of the mutation createAccount. It looks it takes in something called an input, which is createAccount input.
If we scroll down a little bit and click on the input, we're going to see that createAccount is actually a wrapper around name, user name, and password. Every time I create an account, I'm going to need to provide those things.
Now here's where the input comes in handy. Instead of sending all of these variables one at a time, I can wrap them in the input, and then I can send them as one thing.
Here I am going to use the input, and I am going to pass in the input as a variable. We'll set this up at the top. Input is of type createAccount input, and is non-nullable. We'll use the exclamation point. We'll set up this argument to take in the input.
I'll use the query variables panel to pass in these variables, but this time we are going to put everything on that input key. We're going to nest in object here with name, with user name, and with password. Now that I have these input values defined, I need to return something from this mutation.
What this mutation returns is a customer object. This will give us access to all of the fields on the customer. Whenever I create my account, it's going to echo back those account details that I provided in the input. We'll ask for user name and name.
When we send this mutation, we're going to send all of the values from the input object. We're going to get back the user name and the name for the customer that's just been created.
CreatAccount takes in an input called createAccount input. We pass the variables in the query variables panel, and then the mutation returns a customer object so I can access those values that I've just supplied.