I am new to Graphql and I want to update relational types, but I have no idea how to do it.
My type definitions are as following:
type User {
email: String!
username: String!
password: String!
registered_at: Date!
role: String!
Questionnaire: [Questionnaire!]! @relationship(type: "has_questionnaire", direction: OUT)
}
type Questionnaire {
User: [User!]! @relationship(type: "has_questionnaire", direction: IN)
id: ID!
ClosedQuestions: [Answer!]! @relationship(type: "has_answered", direction: OUT)
OpenQuestions: [BigInt]
}
type Answer {
Questionnaire: Questionnaire! @relationship(type: "has_answered", direction: IN)
id: ID!
component: String!
scope: String!
answer: String!
answered_at: Date!
}
- How would I write my mutation if I want to update the OpenQuestions list from a specific Questionnaire (id) from a specific user (username). My attempt was the following:
mutation {
updateUsers(
where: {
username: „Kilian“
id: „Project 1“ ##This id refers to the Questionnaire id
}
update: {
OpenQuestions: [2, 3]
}
) {
users {
Questionnaire {
OpenQuestions
}
}
}
}
/\ But this does not work…
- One step further/deeper: How would I write my mutation if I want to update a specific answer (id) within a specific questionnaire from a specific user?
Many thanks for your help!