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

default discord avatar
6 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!

    Open the post
    Continue the discussion in Discord
    Like what we're doing?
    Star us on GitHub!


    Connect with the Payload Community on Discord



    Can't find what you're looking for?

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