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

default discord avatar
jakey___12 months ago

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) {

and the variables I passed in looked like this

    "data": {
        "email": "",
        "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


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


    Chat on Discord



    Can't find what you're looking for?

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