For the backend part of the coffeekzn.ru web app I decided to choose noSQL database MongoDB and Mongoid instead of ActiveRecord framework.
Let’s create sample Rails API project without ActiveRecord for example:
Great, let’s add mongoid and graphql gems and some other extensions:
Great, now we need to create config/mongoid.yml file and can go forward.
Let’s create shop.rb model:
Nice one. Now, we can create our models from rails console for example, as usual:
Great! Let’s move to our API implementation using GraphQL!
Nothing special here, you can read about basic GraphQL setup in on of my previous posts: GraphQL + Rail.
Let’s take a look into shop_type.rb implementation:
And the query_type.rb file:
Great, let’s check how is our API working on all collection:
And getting one Shop by ID: