Hi, I have the following models and am wondering h...
# prisma-whats-new
f
Hi, I have the following models and am wondering how to to add an automation result to the associated test. I have looked at the one-to-many mutation but it seems i need to have the id already? doesn't really make sense. What i am trying to achieve is to have a table that has the results of the tests which can be many and it be linked to that test. Any help would be great!
l
When creating AutmationResult you need to have Test id and it actually makes sense. Or are you asking about something else?
f
no what im saying is i want to add new automation results to that table that is associated with the test
Copy code
mutation createTestResult {
  addToTestResults(
    automationTestTestId: "cjaa8isvd3bee0183ae0qjd1l"
    resultsAutomationResultId: "cjab8hqii0xo60129j5m5ednp"
  ) {
    automationTestTest {
      testId
    }
    resultsAutomationResult {
      qa
    }
  }
}
that only gives me the query but according to the docs you cannot append to a nested mutation only update it with new ones. What i want to know is how to achieve updating the automation results table with new rows that are associated to an individual test
@Lotafak
l
@fnolla Sorry, I wasn’t by the computer. If I can understand you correctly I am doing the same thing and I can show you an example. One sec
Given schema like
Copy code
type User @model {
  id: ID! @isUnique
  createdAt: DateTime!
  updatedAt: DateTime!

  accounts: [Account!]! @relation(name: "UsersAccount")
}

type Account @model {
  id: ID! @isUnique
  createdAt: DateTime!

  user: User! @relation(name: "UsersAccount")
}
to add Account to the user you need to do something like
Copy code
mutation{
  createAccount(
    userId: "cja9g3eij00oz011072s7635w"
  ) {
    id
  }
}
Hope this is helpful for you. If I still don’t understand you’re question ping me here on in PM, maybe I will be able to help