Can we use UID's obtained from /assign in GraphQL?

I’m unable to use the ID’s retrieved from calling the assign mutation at the /admin endpoint in a graphql mutation.

  • Add mutations don’t have a field for ID
  • Update mutations give me the error: input: updateTest couldn't rewrite mutation updateTest because failed to rewrite mutation payload because ID "0xa297b6" isn't a TestResult

The id 0xa297b6 above is the one I retrieved from assign.

type Test {
  id: ID!
  testResult: TestResult!
}

type TestResult {
  id: ID!
  success: Boolean!
}
mutation UpdateTest {
  updateTest(input: { filter: { id: "0xasd" }, set:  { result: { id: "0xa297b6", success: true }  }) {
    test {
      id
    }
  }
}

Shouldn’t that be testResult and not result in the update payload?

Ah yes, apologies. I thought I updated it, but here’s a correct query:

mutation UpdateTest {
  updateTest(input: { 
      filter: { id: "0x1" }, 
      set:  { testResult: { id: "0xa297b6", success: true }}
    }) {
    test {
      id
    }
  }
}

I’m expecting that the above query will create a TestResult with id 0xa297b6 and success: true but I’m met with an error instead. Any help is massively appreciated!

You’re not updating anything, you’re creating something. For that use add. If you have the id, but you want to update if the id exists, use upsert.

J

1 Like