Giter VIP home page Giter VIP logo

rails-graphql's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.