Skip to content
GraphQL server for SparkEd
JavaScript Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
__tests__
configs
deploy
src
.babelrc
.eslintrc
.gitignore
.travis.yml
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
Passengerfile.json
README.md
app.json
azure-pipelines.yml
cleanDb.sh
gr-updated.png
jest.config.js
package.json
setupTests.js
yarn.lock

README.md

sparked-server

Build Status Build Status Build Status GitHub GitHub repo size David GitHub issues GitHub pull requests

This is an initial graph representation of sparked-server graph representation The above graph is initial and doesn't contain all data, this is likely to be updated.

The following are examples of data of GraphQL queries and mutations

You can try out the online playground here https://sparked-server.herokuapp.com/graphiql

Authentication

All the queries need to be authenticated, you can authenticate via a login mutation Register

mutation {
  register(email: "olivier@gmail.com", password: "oL7vi3#") {
    email
    password
  }
}

The password is hashed and never stored as plain text, the above mutation will return the email and a hashed password.

Login

mutation {
  login(email: "olivier@gmail.com", password: "oL7vi3#")
}

The above mutation will give you results that include a token like this

{
  "data": {
    "login": "eyJhbGciOIkpXVCJ9.eyJ19pZCI6MzM2MDd9.trf9Rm-4w9nFBl4_gF1DfSTH2__xo"
  }
}

You can then use the login token to pass it in headers as "authorization" to authentication any of the queries and mutations below

Adding a course

mutation {
  addCourse(name: "Introduction") {
    name
  }
}

Querying courses

{
  query {
    getCourses {
      _id
      name
    }
  }
}

Development

requirements

  • Node ˆv6
  • npm@latest
  • MongoDb

Clone the repo

git clone https://github.com/OlivierJM/sparked-server.git
cd sparked-server

install dependencies

npm install or yarn

create a file in the root of the project called .env and add your contents as follows.

TOKEN="thegeneratedtoken"
URL= "http://localhost:3000/graphiql"
GRAPHQL_PORT = 3000
MONGO_PORT = 27017
MONGO_URL = "localhost"
dbName = "sparked"
SECRET = "yoursecretkey"
USER="user"
PASS="pass"
TEST_DB="test"

Running

npm dev or yarn dev

Testing

yarn test

Contribution

Fork this repo and clone your forked repo

git clone https://github.com/your-github-username/sparked-server.git

Add this repo to your remotes as upstream.

git remote add upstream https://github.com/SparkEdUAB/sparked-server

Before pushing anything to your fork, always

git pull upstream

Don't forget to add the .env file mentioned above.

Note: Make sure all tests are passing and there are no lint errors before pushing, if you make changes to the code add the tests for that.

Thank you

You can’t perform that action at this time.