Skip to content

Commit

Permalink
Refactor Pages module
Browse files Browse the repository at this point in the history
  • Loading branch information
bricesanchez committed Oct 30, 2017
1 parent 153b1e3 commit 5ea9db4
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 81 deletions.
19 changes: 0 additions & 19 deletions api/app/graph/refinery/api/fields/page_field.rb

This file was deleted.

21 changes: 21 additions & 0 deletions api/app/graph/refinery/api/fields/pages/page_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module Refinery
module Api
module Fields
module Pages
PageField = GraphQL::Field.define do
name 'Page'
description 'Find a page by ID'

type Types::Pages::PageType
argument :id, !types.ID

resolve -> (obj, args, ctx) {
Refinery::Page.find_by_id(args[:id])
}
end
end
end
end
end
20 changes: 20 additions & 0 deletions api/app/graph/refinery/api/fields/pages/pages_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

module Refinery
module Api
module Fields
module Pages
PagesField = GraphQL::Field.define do
name 'Pages'
description 'Find all pages'

type types[Types::Pages::PageType]

resolve -> (obj, args, ctx) {
Refinery::Page.all
}
end
end
end
end
end
21 changes: 0 additions & 21 deletions api/app/graph/refinery/api/types/page_part_type.rb

This file was deleted.

39 changes: 0 additions & 39 deletions api/app/graph/refinery/api/types/page_type.rb

This file was deleted.

23 changes: 23 additions & 0 deletions api/app/graph/refinery/api/types/pages/page_part_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

module Refinery
module Api
module Types
module Pages
PagePartType = GraphQL::ObjectType.define do
name "PagePart"
description "A PagePart"

interfaces [Types::ActiveRecordInterface]

field :slug, types.String
field :position, types.Int
field :title, types.String

field :locale, types.String
field :body, types.String
end
end
end
end
end
39 changes: 39 additions & 0 deletions api/app/graph/refinery/api/types/pages/page_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# frozen_string_literal: true

module Refinery
module Api
module Types
module Pages
PageType = GraphQL::ObjectType.define do
name "Page"
description "A Page"

interfaces [Types::ActiveRecordInterface]

field :parent_id, types.Int
field :path, types.String
field :show_in_menu, types.Boolean
field :link_url, types.String
field :menu_match, types.String
field :deletable, types.Boolean
field :draft, types.Boolean
field :skip_to_first_child, types.Boolean
field :lft, types.Int
field :rgt, types.Int
field :depth, types.Int
field :view_template, types.String
field :layout_template, types.String
field :locale, types.String
field :title, types.String
field :custom_slug, types.String
field :menu_title, types.String
field :slug, types.String
field :meta_description, types.String
field :browser_title, types.String

field :parts, types[Types::Pages::PagePartType]
end
end
end
end
end
4 changes: 2 additions & 2 deletions api/app/graph/refinery/api/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module Types
name 'Query'
description 'The query root of this schema'

field :page, field: Fields::PageField
# field :pages, field: Refinery::Api::Fields::PagesField
field :page, field: Fields::Pages::PageField
field :pages, field: Fields::Pages::PagesField
end
end
end
Expand Down

0 comments on commit 5ea9db4

Please sign in to comment.