Skip to content
GraphQL API for authors and poems
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
bin
config
db
lib/tasks
log
public
storage
tmp
vendor
.gitignore
.ruby-version
Gemfile
Gemfile.lock
README.md
Rakefile
config.ru

README.md

Poetry GraphQL API

Built to teach myself about how to use GraphQL with Rails.

So far, only supports querying.

Here are some examples, though:

Getting Authors by last name:

authors by last name

Getting titles of poems authors have written:

author poems by title

Getting the lines of each poem:

poem lines

You can also get line numbers!

poem lines and line numbers

Getting started

Sorry this is sparse, but just, for now:

  1. rails db:migrate to set up the schema,
  2. rails db:seed to set up the testing data
  3. rails s to start up, and...
  4. You're ready to send queries! Just send a query to /graphql and you'll see the results.

Querying example

  1. In headers: Content-Type: application/json
  2. Request URL: http://localhost:3000/graphql
  3. For the body (in raw JSON), send this:
{
    "query" : "query { authors { poems { title } } }"
}

And you should get something like this back:

{
    "data": {
        "authors": [
            {
                "poems": [
                    {
                        "title": "Sonnet I"
                    },
                    {
                        "title": "Sonnet II"
                    }
                ]
            },
            {
                "poems": [
                    {
                        "title": "Lovers Infiniteness"
                    }
                ]
            }
        ]
    }
}
You can’t perform that action at this time.