ajtran303 / graphql_trigrams

Explore the eight trigrams with my GraphQL API!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trigrams

A GraphQL API for querying the eight trigrams.

Setup

bundle install
rails db:{create,migrate,seed}

Tests

rails db:seed RAILS_ENV=test
bundle exec rspec

Development

rails db:seed RAILS_ENV=production
rails s -p 3000

In your browser, go to:

http://localhost:3000/graphiql

Sample Query

query fetchTrigram {
  trigram(id: 1) {
    id
    trigram
    binary
    element
  }
}

Sample response

{
  "data": {
    "trigram": {
      "id": "1",
      "trigram": "☰",
      "binary": "111",
      "element": "Heaven/Firmament"
    }
  }
}

Production

To use the GraphiQL Interface, go to:

https://graphql-trigrams.herokuapp.com/graphiql

Example curl:

curl --request POST \
-H "Content-Type: application/json" \
-d '{"query":"query{trigram(id:5) {id trigram binary element}}"}' \
https://graphql-trigrams.herokuapp.com/graphql

Sample response:

{"data":{"trigram":{"id":"5","trigram":"","binary":"011","element":"Wind"}}}

About

Explore the eight trigrams with my GraphQL API!


Languages

Language:Ruby 99.2%Language:HTML 0.6%Language:JavaScript 0.2%