https://github.com/aldotestino/hackernews-clone
Hackernews server made with graphql and prisma
https://github.com/aldotestino/hackernews-clone
apollo-server graphql nodejs prisma sqlite typescript
Last synced: 2 months ago
JSON representation
Hackernews server made with graphql and prisma
- Host: GitHub
- URL: https://github.com/aldotestino/hackernews-clone
- Owner: aldotestino
- License: mit
- Created: 2021-03-11T13:08:06.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-12T09:54:09.000Z (over 5 years ago)
- Last Synced: 2025-03-12T01:24:36.900Z (over 1 year ago)
- Topics: apollo-server, graphql, nodejs, prisma, sqlite, typescript
- Language: TypeScript
- Homepage:
- Size: 101 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## hackernews clone
### Stack
* Typescript
* Graphql
* Apollo-server
* Prisma
* Sqlite
### Configuration
* Install all the dependencies
```shell
npm i
```
* Migrate the database with prisma
```shell
npm run migrate
```
* Generate prisma client and types
```shell
npm run generate
```
### Usage
* Start the dev server
```shell
cd server
npm run dev
```
* Go to `http://localhost:4000`
### Examples
#### Mutation
* Signup
```graphql
mutation {
signup(email: "at@email.com", password: "aw3some", name: "at") {
token
user {
name
email
}
}
}
```
* Login
```graphql
mutation {
login(email: "at@email.com", password: "aw3some") {
token
user {
name
email
}
}
}
```
* Change name
```graphql
mutation {
cahngeName(name: "Aldo") {
id
name
}
}
```
* Headers
```graphql
{
"Authorization": "Bearer YOUR_TOKEN"
}
```
* Post a Link
```graphql
mutation {
post(url: "www.github.com/aldotestino", description: "my GitHub page") {
id
url
description
}
}
```
* Headers
```graphql
{
"Authorization": "Bearer YOUR_TOKEN"
}
```
* Delete a Link
```graphql
mutation {
deleteLink(id: "3") {
id
url
description
}
}
```
* Headers
```graphql
{
"Authorization": "Bearer YOUR_TOKEN"
}
```
* Vote a Link
```graphql
mutation {
vote(linkId: "3") {
id
link {
url
}
user {
name
}
}
}
```
* Headers
```graphql
{
"Authorization": "Bearer YOUR_TOKEN"
}
```
#### Query
* Get all the Links
```graphql
query {
feed {
url
description
postedBy {
name
}
}
}
```
* Params:
* filter
* skip
* take
* orderBy
* createdAt
* url
* description
* Get a Link
```graphql
query {
link(id: "3") {
url
description
postedBy {
name
}
}
}
```
* Get all the Users
```graphql
query {
users {
name
email
links {
url
description
}
}
}
```
* Params:
* filter
* skip
* take
* orderBy
* name
* email
* Get a User
```graphql
query {
user(id: "1") {
name
email
links {
url
description
}
}
}
```
#### Subscription
* Subscribe to new links
```graphql
subscription {
newLink {
id
url
description
postedBy {
name
}
}
}
```
* Headers
```graphql
{
"Authorization": "Bearer YOUR_TOKEN"
}
```
* Subscribe to new votes
```graphql
subscription {
newVote {
id
link {
id
url
description
postedBy {
name
}
}
user {
id
name
}
}
}
```
* Headers
```graphql
{
"Authorization": "Bearer YOUR_TOKEN"
}
```