This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* When following freeCodeCamp.org's youtube video tutorial: React / GraphQL Course - Build a social media app (MERNG Stack) | |
* I have got stuck @4:05:00 because I got an error that says: | |
* Uncaught (in promise) Error: Cannot assign to read only property 'getPosts' of object '#<Object>' | |
* that is happening because in apollo-client 3.6 (which I am using) immutability became mandatory, so, we can't assign new key | |
* to existing variable anymore like this: data.getPost = [resault.data.createPost, data.getPosts], but the solution is very simple: | |
*/ | |
// instead of: | |
data.getPost = [resault.data.createPost, data.getPosts] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* When following freeCodeCamp.org's youtube video tutorial: React / GraphQL Course - Build a social media app (MERNG Stack) | |
* I have got stuck @1:18:00 because I got a weired error: Cast to ObjectId failed for value "" at path "_id". | |
* It turn out that that ModelName.findById() method only expect vaild mongodb ID, so all I did is | |
* to use Types.ObjectId.isValid from mongoose to check if the given string is vaild id or not, if not, | |
* Skipped making the query and I threw new "Post not found" Error. | |
*/ | |
import mongoose from 'mongoose'; |