Skip to content

Update embedded Document #12

@vincent41

Description

@vincent41

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions