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
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
chorus-analytics-graphql provides a Sinatra-based graphql endpoint to supplement the python chorus-analytics-api
*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.
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
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.
Deploy the dockerized app via capistrano.
$ bundle exec cap staging deploy BRANCH=branchname
Check http://analytics-api-staging.vpc.voxops.net:9292/graphql
This API can provide information about data resources and refs, but most importantly, it provides metric data. The available metric types are:
point metrics: Returns the current value of whitelisted metrics for a given resource
timeseries metrics: Returns an array of objects {timestamp, value} of the requested metric value changes bucketed by hour.