Skip to content

Commit

Permalink
GraphQL: Return all DB data. Add description field (#1459)
Browse files Browse the repository at this point in the history
  • Loading branch information
mizaki authored Nov 12, 2023
1 parent 840f8df commit fba65ac
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
22 changes: 5 additions & 17 deletions app/graphql/types/volume.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
class Types::Volume < Types::BaseObject
implements Types::Interface::Unit
implements Types::Interface::WithTimestamps

description 'A manga volume which can contain multiple chapters.'

field :id, ID, null: false

field :titles, Types::TitlesList,
null: false,
description: 'The titles for this chapter in various locales'

def titles
{
localized: object.titles,
canonical: object.canonical_title
}
end

field :number, Integer,
null: false,
description: 'The volume number.'

field :published, GraphQL::Types::ISO8601Date,
null: true,
description: 'The date when this chapter was released.',
Expand All @@ -33,6 +17,10 @@ def titles
null: false,
description: 'The isbn number of this volume.'

field :chapters_count, Integer,
null: true,
description: 'The number of chapters in this volume.'

field :chapters, Types::Chapter.connection_type,
null: true,
description: 'The chapters in this volume.'
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20231028222209_add_description_to_volumes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddDescriptionToVolumes < ActiveRecord::Migration[6.1]
def change
add_column :volumes, :description, :jsonb, default: {}, null: false
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2022_12_04_041942) do
ActiveRecord::Schema.define(version: 2023_10_28_222209) do

# These are extensions that must be enabled in order to support this database
enable_extension "citext"
Expand Down Expand Up @@ -1625,6 +1625,7 @@
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.jsonb "thumbnail_data"
t.jsonb "description", default: {}, null: false
end

create_table "votes", id: :serial, force: :cascade do |t|
Expand Down

0 comments on commit fba65ac

Please sign in to comment.