transitco / serviceOffer

GraphQL based GTFS planned service offer management API
3 stars 0 forks source link

ServiceOffer

Retrieve GTFS data with a GraphQL query (nodejs graphql-yoga) from a database (npm gtfs + mongoose + MongoDB)
Use case is made with Montreal public transit agencies: exo, RTL and STM

Required

  1. Docker
  2. Docker Compose

Run serviceoffer

docker login docker.pkg.github.com
Use your Github username and your Github developer token as password.
docker-compose up -d

Rebuild and up only serviceoffer container

docker-compose up -d --build serviceoffer

Test app

GraphQL query console: http://localhost:4000
MongoDB admin: http://localhost:8082/
Connection URI: mongodb://mongo:27017/gtfs

curl --request POST \
  --url http://localhost:3000/import_gtfs
curl --request GET \
  --url http://localhost:3000/export_gtfs

Query available agencies

query {
  agencies {
    agency_key
  }
}

Query RTL specific data

query {
  agencies(agency_key: "rtl_gtfs") {
    routes(route_id: "889") {
      route_long_name
      trips(direction_id: "1") {
        trip_id
      }
    }
  }
}

Modify agency name

mutation {
  agency(agency_key: "rtl_gtfs", agency_name: "ralph") {
    agency_name
  }
}

Modify stop arrival time to 05:32:56

mutation {
  stopTime(agency_key:"rtl_gtfs", trip_id:"889_1_A_F2_8833_24_40", arrival_time:"05:32:56"){
    arrival_time
  }
}

Query from HTTP request (curl)

curl --request POST \
  --url http://localhost:4000/graphql \
  --header 'content-type: application/json' \
  --data '{"query":"{\n  agencies {\n    agency_key\n  }\n}\n"}'

Contribute

You are welcome to contribute either directly via GitHub Pull Request or via Gerrit: https://review.gerrithub.io/q/project:transitco/serviceOffer+status:open

Intial setup to use Gerrit:
pip install git-review

Create a change:

  1. git checkout -b BRANCH_NAME
  2. Modify your files
  3. git add .
  4. git commit -m "MESSAGE"
  5. git review

Modify an existing change:

  1. git review -d CHANGE_ID
  2. Modify your files
  3. git add .
  4. git commit --amend
  5. git review