- GraphQL, Apollo-Server, Prisma, TypeScript-Node
- API Project
- Project includes Pagination, Filter, Sort & Subscription (WebSockets: Apollo-Server)
npm i
npm run dev
http://localhost:3000
-
feed
: Retrieves all links from the backend. Query allows for filter, sorting and pagination arguments -
Sample Query:
query {
feed (take: #) {
count
links {
id
createdAt
description
}
}
}
- Sample
feed
query to retrieve first 10 links from the server:
{
feed(skip: 0, take: 10) {
links {
description
url
postedBy {
name
}
}
}
}
post
: Allows authenticated users to create a new link. To submit a post:
mutation {
post(url: "www.prisma.io", description: "Next-generation Node.js and TypeScript ORM") {
id
}
}
signup
: Create an account for new user. To create a new user:
mutation {
signup(name: "Chris", email: "chris@sample.io", password: "graphql") {
token
user {
id
}
}
}
-
For Signup, copy the authentication token and paste on the
Headers
tab.[x] Authentication Bearer TOKEN_ID -
Invoke the post resolver and validate the provided JWT. With
authentication
header in place, send the following mutation to the server.
mutation {
post(url: "nexusjs.org", description: "Code-First GraphQL schemas for JavaScript/TypeScript") {
id
description
url
postedBy {
id
name
email
}
}
}
login
: Login existing user
mutation {
login(email: "chris@sample.io", password: "graphql") {
token
user {
email
links {
url
description
}
}
}
}
vote
: Allows authenticated users to vote for an existing link
mutation {
vote(linkId: _LINK_ID_) {
link {
url
description
}
user {
name
email
}
}
}
newLink
: Receive realtime updates when a new link is creatednewVote
: Receive realtime updates when a vote was submitted