Skip to content

annacollins85/graphql-101-workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphQL 101 Workshop

Setup

  1. Fork repo
  2. Clone repo from your repositories
  3. run npm install

Instructions

Part 1

  1. Run npm start and visit http://localhost:4000/
  2. Run a query to fetch the name and email for all users
  3. Run a query to fetch the title and author for all posts and for each author return their name and id
  4. Add the field posts to the User type in the typeDefs, what type should it return?
  5. Add a resolver for posts on the User type
  6. Create a new type, Comment with fields id, text, post and author
  7. Add some fake comment data to the database file
  8. Add resolvers for the necessary fields on the Comment type
  9. Add a comments field to User and Post in typeDefs and add the required resolvers
  10. Add a query to fetch a Post given an id as a parameter
  11. Make some queries for your new types

Part 2

  1. Try creating some users
  2. Create a new mutation createPost with the required arguments
  3. Create a resolver for createPost. Make sure to check that an author exists for the author id argument.
  4. If you haven't used an input type in the typeDefs, refactor your code to use one.
  5. Test your code by creating some posts. (Remember, since we are not writing to a database or file, once you refresh the server, the newly created users will have disappeared)
  6. Repeat steps 1 to 4 for createComment

Part 3

  1. Try subscribing to the post subscription and then creating a new post to receive an update.
  2. Create a subscription comment that takes an argument postId which will notify of a new comment published for a given post. Remember, you can pass any string into the PubSub asyncIterator method, so you can pass the postId somewhere in there.
  3. Try subscribing to your new comment subscription for one of your posts. Then create a comment for it.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published