Create a simple GraphQL API
Create the following queries: o Get User o Get Post o Get Comment o Get Comments From Post
Create the following mutations: o Update Post o Delete Post
Implement authentication using Github single sign on
In your terminal or cmd prompt, navigate to the folder you which to place the GraphQL project folder
Then clone it.
git clone https://github.com/saahirfoux/GraphQL.git
After you have cloned the repository run the following commands:
cd [Folder_Name]
npm install
npm run dev
Runs the server in the development mode.
Open http://localhost:3001 to view it in the browser.
You will also see any lint errors in the console.
You can use the following queries and mutations to test the API.
query GetAllUsers{ users { id username email phone website address { street suite city zipcode } posts { title } } } query GetUserByID { user(id: 2) { name } } query GetPostsByUser{ postsByUser(id: 1) { id title userId body } } query GetPostByID { postById(id: 1) { title body id userId } } query GetCommentsByPost { commentsByPost(id: 1) { id postId name email body } } query GetCommentsByIDs { commentByIds(pid:1 cid: 2) { name email id body postId } } mutation updatePostById { updatePost(input: { id: 1, body: "a" title:"Title" }) { id title body } } mutation deletePostById { deletePost(id: 1) { id } }