Skip to content

josej14/apollo2-prisma2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My project

Basic commands

  • Install dependencies using yarn or npm i
  • Launch the backend with yarn dev
  • If you change any model, run the migrations with yarn migrate:save and yarn migrate:up
  • Apply the new migrations to the prisma client with yarn generate
  • Prisma has an IDE for the database. Launch it with yarn studio

Authorization

All the resources (except register and login) have authorization protection. You have to send the JWT token in the headers.

Queries

  • currentUser: Returns user info if it is authenticated
{
  currentUser {
    id
    username
  }
}
  • alumns(take:Int, skip:Int): Returns all the alumns in the DB. Implements pagination using take and skip (optional arguments)
{
  alumns {
    id
    name
    surname
    email
    seminar {
      id
      title
      description
    }
  }
}
  • alumnById(id: Int!): Returns alumn resource by its ID
{
  alumnById (id: 1){
    id
    name
    surname
    email
    seminar{
      id
      title
      description
    }
  }
}
  • alumnByEmail(email: String!): Returns alumn resource by its email
{
  alumnById (email: "[email protected]"){
    id
    name
    surname
    email
    seminar{
      id
      title
      description
    }
  }
}
  • votes(take, skip): Returns all the votes in the DB. Implements pagination using take and skip (optional arguments)
{
  votes{
    id
    quality
    utility
    seminar {
      title
    }
    user {
      username
    }
  }
}
  • votesByUserId(id)
{
  votesByUserId(id: 1){
    id
    quality
    utility
    seminar {
      title
    }
    user {
      username
    }
  }
}
  • votesBySeminarId(id)
{
  votesBySeminarId(id: 1){
    id
    quality
    utility
    seminar {
      title
    }
    user {
      username
    }
  }
}

Mutations

  • register(username, password)
mutation {
  register(username:"test", password:"test") {
    id
    username
  }
}
  • login(username, password)
mutation {
  login(username:"test", password: "test"){
    token
  }
}
  • voteFor(seminar (int), quality, utility): vote a seminar. It uses your token for get your user.
mutation {
  voteFor(seminar: 1,quality: 6, utility:10){
    id
    quality
    utility
    seminar {
      title
    }
    user {
      username
    }
  }
}

Suscriptions

  • userRegistered: Returns a user when it is registered
subscription {
	userRegistered {
    username
  }
}
  • userLogin: Returns a user when it logins
subscription {
	userLogin {
    username
  }
}
  • voteAdded: Returns a vote when it is added
subscription {
  voteAdded {
    user {
      username
    }
    seminar {
      title
    }
    quality
    utility
  }
}
  • seminarStats: Returns seminar stats after a vote is added
subscription {
  seminarStats {
    quality
    utility
		seminar {
      title
    }
    total
  }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published