voxmedia/chorus-analytics-graphql

Name: chorus-analytics-graphql

Owner: Vox Media

Description: GraphQL API for Chorus Analytics

Created: 2018-05-17 18:15:41.0

Updated: 2018-05-24 20:47:03.0

Pushed: 2018-05-24 20:47:00.0

Homepage: null

Size: 42

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

chorus-analytics-graphql provides a Sinatra-based graphql endpoint to supplement the python chorus-analytics-api

Development

Local Development

*This is a work in progress.

You can run this locally. You will need a config/database.yml file. You can copy and edit config/database.yml.example.

Install the gems:

$ bundle install

Launch webserver. Shotgun automatically reloads code on each request, so no need to manually restart the server.

$ shotgun

Hit localhost:/9393/graphql in your browser. You should get an error message: "No query string was present" From here, you can past a json formatted string as a query parameter: http://localhost:9393/graphql?query={analyticsResource(identifier:"1"){title type refs{account}}}

You should get back something like:


ata": {
"analyticsResource": {
  "title": "Republican nativism helped turn California blue. Trump could do the same for the whole country.",
  "type": "chr_entry",
  "refs": [
    {
      "account": "fb_mattyglesias"
    },
    {
      "account": "tw_mattyglesias"
    }
  ]
}


Another way to explore the schema of this GraphQL API is to use graphiql. At this time, it isn't integrated into the server, but you can download the graphiql app.

Running tests

Currently, to get test running, you'll need to generate and populate the test database using the tests in chorus-analytics-api. I plan on adding the test data to this repo's tests soon.

After running the above tests to populate the test database, you can run this repo's tests:

$ rake test
Docker

This application is Dockerized.

$ docker build -t chorus-analytics-graphql
$ docker-compose up

In your browser, hit: localhost:9292 - This uses the puma webserver, hence the different port.

Deploying

Deploy the dockerized app via capistrano.

 $ bundle exec cap staging deploy BRANCH=branchname

Check http://analytics-api-staging.vpc.voxops.net:9292/graphql

Data

This API can provide information about data resources and refs, but most importantly, it provides metric data. The available metric types are:


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.