I have an issue with trying to update a mongoose schema using graphql and .findByIdAndUpdate.
whenever I try to update a document, the the new data is updated correctly, however the unmodified one becomes null.
So if I run this in graphiql:
mutation {
  updateProfile(id: "5b05b4cfd53486377061eab3", name: "dave") {
    id
    name
    age
    interests
  }
}
It returns with this object:
{
  "data": {
    "updateProfile": {
      "id": "5b05b4cfd53486377061eab3",
      "name": "dave",
      "age": null,
      "interests": null
    }
  }
}
The new data has been updated to the document, but the old data has been been deleted.
The idea is to be able to update just a single part of the document without the rest turning into null.
The GraphQL code responsible for updating:
updateProfile: {
            type: profileType,
            args: {
                id:        { type: new GraphQLNonNull(GraphQLID) },
                name:      { type: GraphQLString },
                age:       { type: GraphQLString },
                interests: { type: GraphQLString },
            },
            resolve(parent, args) {
                return Profile.findByIdAndUpdate(args.id, {
                        name:      args.name,
                        age:       args.age,
                        interests: args.interests
                }, {new: true}, (err, Profile) => {
                    if (err) {
                        return res.status(500).send(err);
                    }
                    return;
                }); 
            }
        }
And here's the schema:
const profileSchema = mongoose.Schema({
    name:      String,
    age:       String,
    interests: String,
});
Any and all help is appreciated, thanks in advance!
 
     
    