gustavomrs / rails-graphql

An example of using GraphQL with Rails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

built with love

Rails project example with GraphQL

Installation

$ bundle install
$ rails db:create db:migrate db:seed

Getting Started

$ rails s

Usage examples

example 1

GET localhost:3000/api?query={
  donor(name: "Beth") {
    name
    gender
    organization {
      active
    }
  }
}

result:

{
    "data": {
        "donor": {
            "name": "Beth",
            "gender": "female",
            "organization": {
                "active": false
            }
        }
    }
}

example 2

localhost:3000/api?query={
  organization(active: true) {
    donors {
      name
      gender
    }
  }
}

result:

{
    "data": {
        "organization": {
            "donors": [
                {
                    "name": "Rick",
                    "gender": "male"
                },
                {
                    "name": "Morty",
                    "gender": "male"
                },
                {
                    "name": "Summer",
                    "gender": "female"
                }
            ]
        }
    }
}

About

An example of using GraphQL with Rails


Languages

Language:Ruby 99.1%Language:HTML 0.9%