Instant GraphQL REST-API for Rails from ActiveRecord or Mongoid models https://maxcoto.github.io/graphoid/
Generates a full GraphQL API using introspection of Mongoid or ActiveRecord models.
The API Documentation that displays how to use the queries and mutations that Graphoid automatically generates.
This gem depends on the GraphQL gem. Please install that gem first before continuing
Add this line to your Gemfile:
gem 'graphoid'
$ bundle install
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
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
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.
$ DRIVER=ar DEBUG=true bundle exec rspec
$ DRIVER=mongo DEBUG=true bundle exec rspec
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.
The gem is available as open source under the terms of the MIT License.