0
I am working on a GraphQL mutation to create a project with associated phones
and their parts
, in other words relationship between is so: Phone can have multiple parts
. I have defined a schema for querying phones along with their parts. However, I am encountering an error when trying to create a project with this data structure.
I have the following GraphQL mutation:
mutation update(
$title: String
$phones: [ID]
$parts: [ID]
) {
createProject(
data: {
title: $title
phones: $phones
parts: $parts
}
) {
data {
id
attributes {
title
phones {
data {
id
attributes {
name
parts {
data {
id
}
}
}
}
}
}
}
}
}
And here are my query variables:
{
"title": "test",
"phones": 28,
"parts": [2, 6]
}
The error message I’m getting is: "Field ‘parts’ is not defined by type ‘ProjectInput’." I have checked my schema, and it appears to be correctly defined.
Can anyone help me understand what might be causing this error and how to resolve it? Thank you!
Schema for Reference:
query GetAllPhones {
phones(sort: "name:asc", pagination: { limit: 99999 }) {
data {
id
attributes {
parts {
data {
id
}
}
}
}
}
}