Update embedded Document
vincent41 opened this issue · 0 comments
vincent41 commented
Thanks for a great cheat. I'm looking for update embedded documents, but i can't find it anywhere. For example GraphQL query:
mutation (_id: "12" input: { work: "911" } ) { phone{ work privat } }
And hier is the problem, If I only want to change one field, another field will be deleted
schema:
type User implements Entity {
_id: ID
phone: PhoneType
}
type PhoneType {
wokr: String
privat: String
}
type Mutation {
update(_id: ID input: PhoneInput ): User
}
resolver
Mutation: {
update: async (_, { _id, input }) => {
const user = await User.findOneAndUpdate({ _id: _id }, { $set: input }, { new: true })
return user
}
}
HELP PLEASE