Skip to content

exlskills/gql-server

Repository files navigation

Docker Automated build

EXLskills GraphQL API Server

Requirements

You may be able to get away with more/less than what's described below, but we can't recommend anything outside of these options:

Operating Systems:

  • Ubuntu 16.04
  • OS X 10.13+
  • Windows has not been thoroughly tested, although it has worked and should work... Windows-related contributions are welcome

Other Dependencies:

  • MongoDB v3.4+ (Recommend v3.6+)
  • NodeJS v8.10+
  • NPM v6.1+

Installation

git clone https://github.com/exlskills/gql-server

cd gql-server

npm install

Running

MongoDB should be running

Set up generated files:

npm run update-schema

TODO discuss seeding data

Start a local server:

npm start

Configuration

At startup, the server reads the configuration information from the Operating System's Environment Variables and/or from the .env file located in the installation root directory. See dotenv syntax rules for .env formatting. The same format is also generally applicable to docker environment variables files that can be used to pass parameters into containers via --env-file option and to docker-compose environment file

For local testing or development, copy the sample provided .default.env into .env and set the necessary values, e.g., set

DB_NAME=my_dev

GraphQL Schema

If at any time you make changes to src/schema.js or src/relay-*/*.js, stop the server, regenerate src/schema.graphql, and restart the server:

npm run update-schema
npm start

GraphiQL: http://localhost:8080/graph

Course Delivery Schedule Loader API

The API provides functionality to load Course Delivery Schedule into the system from a YAML file formatted as per src/data-load/course-delivery-schedule/data/course-delivery-sample.yaml. The content of file is pulled from the GitHub repository and then pushed back ("feedback commit") with the record IDs written into the file to facilitate updates and reloads.

The API is invoked via POST to /course-delivery-schedule

As the process needs write access to the repository containing the YAML file, environment variable GITHUB_USER_TOKEN should be set according to GitHub Personal Access Token setup. According to the JS gihub API documentation, only the token is used in the authentication call, the GitHub User ID is not required. Additionally, environment variable GITHUB_WH_TOKEN should be set with the value matching the GitHub webhook secret

The commit to the GitHub repository should contain only the schedule file(s) - the API is coded to process the entire content of the commit, as per the GitHub webhook, except any files that contain README or LICENSE in their name, case-insensitive, as well as .gitignore. The return codes are:

  • 200 - success
  • 304 - bypassing webhook generated by the feedback commit or no files to process in the commit (e.g., README only was committed)
  • 400 - malformed request body, payload or X-Hub-Signature does not match expected value
  • 403 - GitHub user token authentication error
  • 422 - error creating feedback commit
  • 500 - other error

The branch of the GitHub repository containing the schedule to be processed can be controlled via the GH_WEBHOOK_BRANCH Environment variable. By default, only the master branch is in scope. As GitHub webhook is set at the repository vs. branch level, to limit the branch(es) that trigger the API, set the value of GH_WEBHOOK_BRANCH to another branch or a comma-separated list of branches, no spaces. The values are case-sensitive.

License

This software is offered under the terms outlined in the LICENSE.md file provided with this notice. If you have any questions regarding the license, please contact [email protected]

Enterprise / Commercial Licensing & Support

For enterprise licenses and/or support, please send an email enquiry to [email protected]

About

The GraphQL API server that powers EXLskills.com

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published