Skip to content

Instant GraphQL REST-API for Rails from ActiveRecord or Mongoid models https://maxiperezc.github.io/graphoid/

License

Notifications You must be signed in to change notification settings

oxeanbits/graphoid

 
 

Repository files navigation

graphoid

CI Gem Version Maintainability

Generates a full GraphQL API using introspection of Mongoid models.

API Documentation

The API Documentation that displays how to use the queries and mutations that Graphoid automatically generates.

Dependency

This gem depends on the GraphQL gem. Please install that gem first before continuing

Installation

Add this line to your Gemfile:

gem 'graphoid', git: 'https://github.com/oxeanbits/graphoid.git', tag: '1.0.0'
$ bundle install

Usage

Create the file config/initializers/graphoid.rb and determine which models will be visible in the API by select the models to generate Types, Queries and Mutations.

Rails.application.config.after_initialize do
  Graphoid.configure do |config|
    config.driver = :mongoid
  end

  Graphoid.initialize
  Graphoid::Types.initialize(User, Contract)
  Graphoid::Queries.generate(User, Contract)
  Graphoid::Mutations.generate(User, Contract)
end

Examples

And an example with Mongoid in the Tester Mongo folder In this same repository.

Contributing

  • Live Reload
  • Aggregations
  • Permissions on fields
  • Relation with aliases tests
  • Write division for "every" in Mongoid and AR
  • Sort top level models by association values
  • Filter by Array or Hash.
  • has_one_through implementation
  • has_many_selves tests
  • has_and_belongs_to_many_selves tests
  • Embedded::Many filtering implementation
  • Embedded::One filtering with OR/AND

Testing

$ cd spec/tester_mongo
$ DRIVER=mongo DEBUG=true bundle exec rspec

Thank You !!

Ryan Yeske for the whole idea and for validating that metaprogramming this was possible.

Andres Rafael for working so hard on connecting the gem on the frontend and finding its failures.

License

The gem is available as open source under the terms of the MIT License.

About

Instant GraphQL REST-API for Rails from ActiveRecord or Mongoid models https://maxiperezc.github.io/graphoid/

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 98.5%
  • Other 1.5%