Coder Social home page Coder Social logo

obiter's Introduction

obiter

๐Ÿ˜Ž To Start

Clone the project

$ git clone [email protected]:aiotrope/obiter.git myproject
$ cd myproject

Install the dependencies

$ npm install

Create .env file at the root of the project directory and setup the environment variables. The 2 required variables are: MONGO_DEV, and TOKEN_SECRET. e.g.

# .env

MONGO_DEV=mongodb://localhost:27017/mydb # MongoDB URL connection string
JWT_KEY=b2e5943db539285644c838de0015a3ffc2c2cf3a11104adeb280a06cb0ba46f3fc70503d7b5a4d66362050ff01236161 # as secret key

Run the code

# serve backend at localhost:4000
$ npm run dev

๐Ÿค– Model Fields & References

User Model

  • email: String
  • hash: hashed password
  • posts: Array of posts made by the user; reference to PostModel
  • commnentsMade: Array of comments created by the user; reference to CommentModel

Post Model

  • title: String
  • postedBy: Object; reference to user who create the post
  • comments: Array of comments belong to the post

Comment Model

  • text: String
  • commenter: Object; reference to user who made the comment
  • commentFor: Object; reference to PostModel for which the comment is made

๐Ÿงฉ Sample queries, mutations and subscriptions

User Signup

   mutation SIGNUP($email: String!, $password: String!) {
  signup(email: $email, password: $password) {
    id
    email
    posts {
      id
    }
    commentsMade {
      id
    }
  }
}

Login

   mutation SIGNIN($email: String!, $password: String!) {
  signin(email: $email, password: $password) {
    value
  }
}

Post Creation

require authorization token

mutation CREATE_POST($title: String) {
  createPost(title: $title) {
    id
    title
    comments {
      id
      text
    }
    postedBy {
      id
      email
    }
  }
}

All Posts

query POSTS {
  posts {
    id
    title
    comments {
      id
      text
    }
    postedBy {
      id
      email
    }
  }
}

Post Subscription

require authorization token

subscription POST_ADDED {
  postAdded {
    id
    title
    comments {
      id
      text
    }
    postedBy {
      id
      email
    }
  }
}

Update Post

require authorization token

    mutation UPDATE_POST($postId: ID!, $updatePostInput: UpdatePostInput!) {
    updatePost(postId: $postId, updatePostInput: $updatePostInput) {
    id
    title
    comments {
      id
      text
    }
    postedBy {
      id
      email
    }
  }
}

Updated Post Subscription

require authorization token

subscription POST_UPDATED {
  postUpdated {
    id
    title
    comments {
      id
      text
    }
    postedBy {
      id
      email
    }
  }
}

Create Comment

require authorization token

mutation CREATE_COMMENT($postId: String!, $commentInput: CommentInput!) {
  createComment(postId: $postId, commentInput: $commentInput) {
    id
    text
    commenter {
      id
      email
    }
    commentFor {
      id
      title
    }
  }
}

All Comments

query COMMENTS {
  comments {
    id
    text
    commentFor {
      id
      title
    }
    commenter {
      id
      email
    }
  }
}

Comment Subscription

require authorization token

subscription COMMENT_ADDED {
  commentAdded {
    id
    text
    commenter {
      id
      email
    }
    commentFor {
      id
      title
    }
  }
}

obiter's People

Contributors

aiotrope avatar arnelimperial avatar

Watchers

 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.