I am taking a deep dive into React and NextJS. I want to stand up something a bit complex to play with so I'll make use of my turnkey rails project that designed to standup a rails app and includes scripts to stand up a ruby graphql.

Rails

git clone git@gitlab.com:dnajd/docker-rails.git void.beesbot.com
cd void.beesbot.com
make init

We will use NextJs, so we'll need the concept of a session

bin/rcmd rails g model Session session_guid:string

And we'll create star ships to make a mini game

bin/rcmd rails g model StarShip session_id:integer power:integer lat:float lng:float name:string shields:integer

We'll add defaults to a few of the starship columns in the migration

            t.integer :power, default: 100
            t.float :lat, default: 0
            t.float :lng, default: 0
            t.integer :shields, default: 100

And validations / associations for the models

class Session < ApplicationRecord
    validates :session_guid, presence: true
    has_one :star_ship
end

class StarShip < ApplicationRecord
    validates :session_id, presence: true
    belongs_to :session
end

And seed some data to prove it works

require 'securerandom'

Session.delete_all
StarShip.delete_all

ActiveRecord::Base.transaction do

    session = Session.create!(session_guid: SecureRandom.uuid)

    ship = StarShip.create!(
        session_id: session.id,
        name: 'The Ship'
    )

end

Graphql

And because I've already done this before

make graphql_it

And expose some data to play with

bin/rcmd rails g graphql:object Session
bin/rcmd rails g graphql:object StarShip