Skip to content

A Fresh new GraphQL server for Rails applications, with a focus on natural and Ruby-like DSL.

License

Notifications You must be signed in to change notification settings

olucasmarquess/rails-graphql

 
 

Repository files navigation

Rails GraphQL - GraphQL meets RoR with the most Ruby-like DSL

Gem Version

Wiki | Bugs

Description

rails-graphql is a fresh new implementation of a GraphQL server, designed to be as close as possible to Rails architecture and interfaces, which implies that it has shortcuts, lots of syntax sugar, and direct connection with Rails features like ActiveRecord and ActionCable.

This gem has its own parser, written from scratch, using the C-API of Ruby, which empowers it with an outstanding performance. Plus, all the features provided were carefully developed so that everyone will feel comfortable and able to apply in all application sizes and patterns.

3 Simple Steps

Install

# Add the gem to your Gemfile
$ bundle add rails-graphql
# Then run the Rails generator
$ rails g graphql:install

Define

# app/graphql/app_schema.rb
class GraphQL::AppSchema < GraphQL::Schema
  field(:welcome).resolve { 'Hello World!' }
end

Run

$ curl -d '{"query":"{ welcome }"}' \
       -H "Content-Type: application/json" \
       -X POST http://localhost:3000/graphql
# {"data":{"welcome":"Hello World!"}}

Features

GraphQL Parser : Supporting the October 2021 spec

Schemas : One or multiple under the same application or across multiple engines

Queries : 3 different ways to defined your queries, besides sources

Mutations : 3 different ways to defined your mutations, besides sources

Subscriptions : 3 different ways to defined your subscriptions, besides sources

Directives : 4 directives provided: @deprecated, @skip, @include, and @specifiedBy : Event-driven interface to facilitate new directives

Scalars : All the spec scalars plus: any, bigint, binary, date, date_time, decimal, json, and time

Sources : A bridge between classes and GraphQL types and fields : Fully implemented for ActiveRecord for PostgreSQL, MySQL, and SQLite databases.

Generators : Rails generators for you to get start quickly

Shortcuts : Several shortcuts through ::GraphQL module to access classes within the gem

Type Map : A centralized place where all the types are stored and can be resolved

Global ID : All objects defined supports .to_global_id, or simply .to_gid

Subscriptions Provider : Current supporting only ActionCable provider and Memory store

Introspection : All necessary types for introspection with proper descriptions : Plain text display of the schemas

Testing : Support to validate GraphQL documents and stub values before requests

Error Handling : Full support to rescue_from within schemas : A gracefully backtrace display

How to contribute

To start, simply fork the project.

Run local tests using:

$ bundle install
$ bundle exec rake compile
$ bundle exec rake test

Finally, change the code and submit a pull request.

License

Copyright © 2020-2023 VirtualShield LLC. See The MIT License for further details.

About

A Fresh new GraphQL server for Rails applications, with a focus on natural and Ruby-like DSL.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 93.0%
  • C 6.1%
  • Other 0.9%