Class: Blog::Types::QueryType

Inherits:
BaseObject
  • Object
show all
Defined in:
app/graphql/blog/types/query_type.rb

Instance Method Summary collapse

Instance Method Details

#article(id:) ⇒ Object



19
20
21
# File 'app/graphql/blog/types/query_type.rb', line 19

def article(id:)
  Article.find(id)
end

#articles(page: 1, tag_id: nil, query: nil) ⇒ Object



11
12
13
# File 'app/graphql/blog/types/query_type.rb', line 11

def articles(page: 1, tag_id: nil, query: nil)
  Article.preload(:tag).filters({page: page, tag_id: tag_id, query: query})
end

#tag(id:) ⇒ Object



32
33
34
# File 'app/graphql/blog/types/query_type.rb', line 32

def tag(id:)
  Tag.find(id)
end

#tagsObject



24
25
26
# File 'app/graphql/blog/types/query_type.rb', line 24

def tags
  Tag.all
end