joan
02/15/2019, 8:54 PMevent
with a new array of `places`: Reason: 'places' Expected 'PlaceUpdateManyInput', found not an object
const UPDATE_EVENT_MUTATION = gql`
mutation UpdateEventMutation($id: ID!, $title: String!, $slug: String!, $description: String, $dates: [String], $places: [PlaceInput]) {
updateEvent(id: $id, title: $title, slug: $slug, description: $description, dates: $dates, places: $places) {
id
title
description
dates
places {
name
url
}
}
}
`;
// Resolver
updateEvent(parent, { id, title, slug, description, dates, places }, context) {
return context.prisma.updateEvent({
where: { id },
data: { title, slug, description, dates: { set: dates }, places },
});
},
// graphql schema
type Mutation {
updateEvent(id: ID!, title: String!, slug: String!, description: String, dates: [String], places: [PlaceInput]): Event
}
input PlaceInput {
name: String!
url: String
}
type Place {
id: ID!
name: String!
url: String
}
type Event {
id: ID!
slug: String!
title: String!
description: String
dates: [String]
places: [Place]
menus: [String]
}
joan
02/15/2019, 8:55 PMmarcus
02/15/2019, 9:26 PMmarcus
02/15/2019, 9:27 PMjoan
02/15/2019, 9:43 PMconnect
or the create
that I have to use?joan
02/15/2019, 9:44 PMjoan
02/15/2019, 10:44 PMplaces: { create: places }
, I was able to save data, but it doesn't update it. It keeps increasing the recordsjoan
02/15/2019, 10:44 PMplaces: {
update: {
where: { id },
data: { places }
}
}
I though it would update each place but it throws an errorjoan
02/15/2019, 11:16 PMjoan
02/16/2019, 6:34 PMplaces: {
update: {
where: { id: places.id },
data: {
name: places.name,
url: places.url
}
}
}
marcus
02/18/2019, 9:05 AMjoan
02/18/2019, 9:45 AMconnect
when adding placesjoan
02/18/2019, 9:45 AMsubscriptions
to update the UI whenever a new place
is added