Skip to content

Commit

Permalink
Updates readme to reflect graphql 2.0.x changes (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
niltonvasques authored Apr 23, 2023
1 parent 9f59a5b commit 7ab4f9b
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

<img src="https://cl.ly/aeaacddab2e2/graphoid.png" height="150" alt="graphoid"/>

[![CI](https://github.com/oxeanbits/graphoid/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/oxeanbits/graphoid/actions/workflows/build.yml)
[![Gem Version](https://img.shields.io/badge/gem%20version-0.2.0-green)](https://rubygems.org/gems/graphoid)
[![Maintainability](https://api.codeclimate.com/v1/badges/96505308310ca4e7e241/maintainability)](https://codeclimate.com/github/maxiperezc/graphoid/maintainability)

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

## API Documentation
The [API Documentation](https://maxcoto.github.io/graphoid/) that displays how to use the queries and mutations that Graphoid automatically generates.
Expand All @@ -19,36 +18,35 @@ Please install that gem first before continuing
Add this line to your Gemfile:

```ruby
gem 'graphoid', git: 'https://github.com/oxeanbits/graphoid.git', tag: '0.2.0'
gem 'graphoid', git: 'https://github.com/oxeanbits/graphoid.git', tag: '1.0.0'
```

```bash
$ bundle install
```

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

```ruby
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

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.

```ruby
class Person
include Graphoid::Queries
include Graphoid::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
You can find an example that uses ActiveRecord in the [Tester AR folder](https://github.com/maxiperezc/graphoid/tree/master/spec/tester_ar)
And an example with Mongoid in the [Tester Mongo folder](https://github.com/maxiperezc/graphoid/tree/master/spec/tester_mongo)

And an example with Mongoid in the
[Tester Mongo folder](https://github.com/oxeanbits/graphoid/tree/master/spec/tester_mongo)
In this same repository.


Expand All @@ -70,7 +68,7 @@ In this same repository.

## Testing
```bash
$ DRIVER=ar DEBUG=true bundle exec rspec
$ cd spec/tester_mongo
$ DRIVER=mongo DEBUG=true bundle exec rspec
```

Expand Down

0 comments on commit 7ab4f9b

Please sign in to comment.