Contributors is a GraphQL API written in Go. It uses MongoDB as a database to store and Redis to cache and rate limit the requests. To deploy the project Kubernetes is used (manifests are available in the Kubernetes
directory).
Make sure you have Go and MongoDB installed. And you have alredy cloned the repository.
First, copy the .env.example
file to .env
and change the values to your own. You can use below bash command to do that.
cp .env.example .env
Then, run the following commands to start the server.
go mod download
go run main.go
The easiest way to run this project in cloud with use of Gitpod. Just click on the button below to start the project in Gitpod.
Make sure you have Docker and Docker Compose installed. And you have already cloned the repository.
Then, run the following commands to start the server. It will step up a MongoDB container and a Go API container.
docker compose up
You can use the GraphQL Playground to interact with the API. It will be available at http://localhost:8080/
if you are running the API locally.
The userId
for a contributor is the U
+ githubUsername
. For example, if the githubUsername
is example
, then the userId
will be Uexample
. This is done to make sure that the userId
is unique. contributions
is optional in the input.
mutation {
addAContributor(
input: {
githubUsername: "example"
name: "Pradumna Saraf"
email: "example@example.com"
contributions: {
projectName: "example"
type: "code"
date: "2021-09-01"
}
}
) {
userId
githubUsername
name
email
contributions {
contributionId
projectName
type
date
}
}
}
query {
getAllContributors {
userId
githubUsername
name
email
}
}
query {
getAContributor(userId: "Uexample") {
userId
githubUsername
name
email
}
}
In update we don't update the userId
if githubUsername
is changed. This is done to make sure that the userId
is always remain same.
mutation {
updateAContributor(
userId: "Uexample"
input: {
name: "example"
email: "example@example.com"
githubUsername: "example"
}
) {
userId
githubUsername
name
email
}
}
mutation {
deleteAContributor(userId: "Uexample") {
userId
githubUsername
name
email
}
}
The contributionId
for a contribution is the C
+ repositoryName
. For example, if the repositoryName
is example
, then the contributionId
will be Cexample
. This is done to make sure that the contributionId
is unique.
mutation {
addAContribution(
userId: "Uexample"
input: { projectName: "example", type: "code", date: "2021-09-01" }
) {
contributionId
}
}
mutation {
deleteAContribution(contributionId: "Cexample") {
contributionId
}
}
This project is licensed under the GNU General Public License v3.0 - see the LICENSE for details.
If you discover a security vulnerability within this project, please check the security policy for more information.