Hiya, what is wrong with my `dates` field? I get t...
# orm-help
j
Hiya, what is wrong with my
dates
field? I get this error message:
Copy code
[GraphQL error]: Message: Variable '$data' expected value of type 'EventUpdateInput!' but got: {"title":"title here","slug":"title-here","description":"lorem ipsum.","dates":["2019-02-28T11:11"]}. Reason: 'dates' Expected 'EventUpdatedatesInput', found not an object. (line 1, column 43):
mutation ($where: EventWhereUniqueInput!, $data: EventUpdateInput!) {
                                          ^, Location: [object Object], Path: updateEvent
I get that error when trying to run a mutation to update an event:
Copy code
const UPDATE_EVENT_MUTATION = gql`
  mutation UpdateEventMutation($id: ID!, $title: String!, $slug: String!, $description: String, $dates: [String]) {
    updateEvent(id: $id, title: $title, slug: $slug, description: $description, dates: $dates) {
      id
      title
      description
      dates
    }
  }
`;
graphql.schema:
Copy code
type Mutation {
  updateEvent(id: ID!, title: String!, slug: String!, description: String, dates: [String]): Event
}

type Event {
  id: ID!
  slug: String!
  title: String!
  description: String
  dates: [String]
  places: [Place]
  menus: [String]
}
auto generated prisma.schema:
Copy code
input EventUpdatedatesInput {
  set: [String!]
}

updateEvent(data: EventUpdateInput!, where: EventWhereUniqueInput!): Event
h
can you share your resolver code as well?
j
Copy code
updateEvent(parent, { id, title, slug, description, dates }, context) {
     return context.prisma.updateEvent({
       where: { id },
       data: { title, slug, description, dates },
     });
   },
h
you need to use set for dates
use this
Copy code
updateEvent(parent, { id, title, slug, description, dates }, context) {
     return context.prisma.updateEvent({
       where: { id },
       data: { title, slug, description, dates: { set: dates }  },
     });
   },
j
thanks! now it works. I didn't know I have to use
set
for arrays