newtonjose / my-twitter

A simple Twitter API using Elixir, Phoenix, Absinthe and GraphQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

my-twitter

A simple GraphQL API implementing the objects User, Tweet using the Twitter API as docs ref.

Instalation

// Setup using docker-compose to get backend and front

GraphQL Exemples

  • To use the API,

Fiist create a user

mutation createUser {
  userSignUp(
    object: {
      email: "email@domain.<any>",
      password:"passwd",
      screenName: "my_nickname",
    }
  ) {
    id
  }
}

Authenticate to get JWT token

mutation authenticateUser {
  userAuth(
    object: {
      email: "email@domain.<any>",
      password:"passwd"
    }
  ) {
    user{
      id
      name
      description
      screenName
    }
    token
  }
}

Ccpy the token and add on Headers

Header Name Header Value
Authorization Bearer token
mutation {
  createTweet(object: {
    text: "Fist tweet create after one week"
  }) {
    id
    text
    createdAt
    favorited
    retweeted
    user {
      id
    }
  }
}

// queries, mutations: create, update, delete

DB Schemas (docs)

  • User
mix phx.gen.context Accounts User users \
    name:string \
    email:strig \
    screen_name:string \
    description:string \
    location:string \
    protected:boolean \
    followers_count:integer \
    favourites_count:integer \
    created_at:string \
    password_hash:string
  • Tweet
mix phx.gen.context Tweets Tweet tweets \
    text:text \
    reply_count:integer \
    retweet_count:integer \
    favorite_count:integer \
    favorited:boolean \
    retweeted:boolean \
    in_reply_to_status_id:integer \
    in_reply_to_user_id:integer \
    in_reply_to_screen_name:string \
    created_at:string \
    user_id:references:users
mix ecto.migrate

About

A simple Twitter API using Elixir, Phoenix, Absinthe and GraphQL


Languages

Language:Elixir 100.0%