Skip to content
Instant GraphQL REST-API for Rails from ActiveRecord or Mongoid models https://maxiperezc.github.io/graphoid/
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.
docs Bump macaddress from 0.2.8 to 0.2.9 in /docs/assets/plugins/lightbox Jun 13, 2019
lib improving rubocop over time Jun 8, 2019
spec adding tests coverage Jun 18, 2019
.gitignore adding tests coverage Jun 18, 2019
.rubocop.yml improving rubocop over time Jun 8, 2019
.ruby-version adding ruby version file May 8, 2019
.travis.yml
Gemfile
Gemfile.lock
MIT-LICENSE init graphoid Oct 5, 2018
README.md
Rakefile v0.0.4 Apr 11, 2019
graphoid.gemspec version 0.1.0 May 20, 2019

README.md

graphoid

Build Status Gem Version Maintainability Test Coverage

Generates a full GraphQL API using introspection of Mongoid or ActiveRecord models.

API Dodocumentation

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'
$ bundle install

Database

Create the file config/initializers/graphoid.rb And configure the database you want to use in it (:mongoid or :active_record)

Graphoid.configure do |config|
  config.driver = :mongoid
end

Usage

You can determine which models will be visible in the API by including the Graphoid Queries and Mutations concerns

class Person
  include Graphoid::Queries
  include Graphoid::Mutations
end

Examples

You can find an example that uses ActiveRecord in the Tester AR folder
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

$ DRIVER=ar DEBUG=true bundle exec rspec
$ 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.

You can’t perform that action at this time.