Mutations: Create or Update methods to update information

Hello, I created a model to store user information, concretely the bookmarked assets in a webpage stored in a list as follows with maxLength 1000000:

bookmarkedAssets: [Int] @list(maxLength: 1000000)

I can only add/update information by using the create method from Graphql, but I think I should use the update Method (image attached) when I want to update the information related to a user. Am I wrong?

Also, I dont know where could I get the node id to use the mutation update method, where this id is required as parameter along with content:

Thanks in advance!

Hey, @Eloy , thanks for reaching out :slight_smile: !

You can get node ids from create mutations of queries and then use it with update mutations.

To get node ids from create mutations you should be able to do something like:

mutation {
  createUserInformationTestingInput(input:: ...) {
    document {
      id <- this is your node id
      ...
    }
  }
}

To get node id from queries you should be able to do something like:

query {
  viewer {
    userInformationTesting {
      id <- this is your node id
    }
  }
}

I may be slightly wrong with these examples, but that’s the general idea. Your UserInformationTesting documents have ids which can be used for update mutations.

If you still struggle to make this work, you can share your composite with me and I’ll be able to tell you exactly how to do this :slight_smile: .

2 Likes