Socket
Book a DemoInstallSign in
Socket

graphoid

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphoid

0.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source
graphoid

Build Status Gem Version

This gem is used to generate a full GraphQL API using introspection of Mongoid or ActiveRecord models. After installing it, you will have create, update, delete, and query actions on any rails models you want.

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

Configuration

Create the file config/initializers/graphoid.rb And configure the database you want to use in it.

Graphoid.configure do |config|
  config.driver = :mongoid
  # or
  config.driver = :active_record
end

Usage

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

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

You can also include a special concern that will let you create virtual fields and forbid access to existing fields

class Person
  include Graphoid::Graphield

  graphield :full_name, String # virtual fields need to resolve as a method
  graphorbid :balance # attribute balance will not be exposed in the API

  def full_name
    "#{first_name} #{last_name}"
  end
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 of this same repository.

graphoid

Contributing

  • Install code climate
  • Functionality to sort top level models by association values
  • Filter by Array or Hash.
  • Fix Rubocop errors.
  • Live Reload
  • AR eager load
  • Relation with aliases tests
  • Aggregations
  • Remove config / auto-setup AR-Mongo
  • Write division for "every" in Mongoid and AR
  • Permissions on fields
  • has_one_through implementation
  • has_many_selves (employee) tests
  • has_and_belongs_to_many_selves (followers) 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

License

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

FAQs

Package last updated on 20 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.