You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Operation has been confirmed for data acquisition, creation, and updating when there is no relationship
Problem
If you request an update for a schema that has the following relationships, the following error will occur. Why?
If I exclude the related property (status: ScheduleState!), it works, so I think it's a problem with the relation.
Do I need to write my own resolver in such a case?
Error: Cannot return null for non-nullable field Schedule.status.: {"response":{"errors":[{"message":"Cannot return null for non-nullable field Schedule.status.","locations":[{"line":11,"column":5}],"path":["updateSchedule","status"]}],"data":{"updateSchedule":null},
Code
//schema
type Mutation {
updateSchedule(id: ID!,params: UpdateScheduleInput): Schedule
}
type Schedule {
id: ID!
startAt: DateTime
endAt: DateTime
status: ScheduleState!
}
type ScheduleState {
id: ID!
name: String!
}
input UpdateScheduleInput {
id: ID!
startAt: DateTime
endAt: DateTime
statusId: ID
}
//query
export const updateSchedule = gql`
mutation updateSchedule($id: ID!, $params: UpdateScheduleInput) {
updateSchedule(id: $id, params: $params) {
id
startAt
endAt
status {
id
name
}
}
}
`
Tried
By the way, I tried the following resolver, but it didn't work
You’re definitely on the right track with the resolver. Mirage GraphQL tries to auto-resolve certain queries, but it’s pretty limited, and in your case the auto-resolution falls short.
It’s not obvious, but you’ll need to decorate the records from Mirage a bit to satisfy what GraphQL expects. For example, each object in the response needs to have a __typename field.
You can import a function from Mirage GraphQL that will decorate the records accordingly:
Prerequisites
Operation has been confirmed for data acquisition, creation, and updating when there is no relationship
Problem
If you request an update for a schema that has the following relationships, the following error will occur. Why?
If I exclude the related property (status: ScheduleState!), it works, so I think it's a problem with the relation.
Do I need to write my own resolver in such a case?
Error: Cannot return null for non-nullable field Schedule.status.: {"response":{"errors":[{"message":"Cannot return null for non-nullable field Schedule.status.","locations":[{"line":11,"column":5}],"path":["updateSchedule","status"]}],"data":{"updateSchedule":null},
Code
Tried
By the way, I tried the following resolver, but it didn't work
The text was updated successfully, but these errors were encountered: