Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Are there examples of calling payload's "createX" mutations?

default discord avatar
jakey___last year
1

I've been doing fine querying but I'm just having a hard time understanding the mutation side of things. If I just had an example or two of how to do that in payload, that would be immensely helpful.



thank you



ok, I was able to get over this very basic aspect of gql, lol.



I created a collection called "accounts" that for now just has a couple simple text fields



Then the mutation looks like this:

mutation createAccount($data: mutationAccountInput!) {
  createAccount(data: $data) {
    email
    authKey
    sessionKey
    authKeyExpiresAt
  }
}


and the variables I passed in looked like this

{
    "data": {
        "email": "test@test.com",
        "authKey": "5555555",
        "sessionKey": "5555555",
        "authKeyExpiresAt": "5555555"
    }
}


mutation successful!



The thing that confused me at first was the fact that the fields you list out are for the

return

data. They're not actually needed to perform the mutation.



I also was missing the

!

in the mutation argument type.



Hope this is useful to someone in the future!

    Star on GitHub

    Star

    Chat on Discord

    Discord

    online

    Can't find what you're looking for?

    Get help straight from the Payload team with an Enterprise License.