StackOverflow!
One day ago I've started to learn a new thing for me - GraphQL. Now I know how to add and read objects from a database using GraphQL. I have tried to find an answer to question "how to remove an object from database". But it's no luck. Can you help me with this "hard" (for you) question?
Thanks for your answers!
I found it! Maybe someone needs the answer.
Use Model.findByIdAndDelete(id, options, callback);
My code:
deleteImage: {
type: ImageType,
args: {
id: { type: GraphQLID }
},
resolve(parent, args) {
return Image.findByIdAndDelete(args.id);
}
}
It works!