Git Product home page Git Product logo

graphql-workshop-1's Introduction

GraphQL-workshop-1

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 posts to the User type, what type should it return?
  5. Add a resolver for posts on User
  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 comment fields to User and Post and add the required resolvers
  10. Make some queries for your new types

Part 2

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

Part 3

  1. Try subscribing to the post subscription and then creating a new post.
  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 function, so you can pass the postId in there.
  3. Try subscribing to your new comment subscription for one of your posts. Then create a comment for it.

graphql-workshop-1's People

Contributors

annacollins85 avatar dependabot[bot] avatar tothviktoria avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.