class Rumors::Api::Client::Utils::ListArticles

Public Class Methods

new(text) click to toggle source
# File lib/rumors/api/client/utils/list_articles.rb, line 6
def initialize(text)
  @text = text
end

Public Instance Methods

purify_gql_query() click to toggle source
# File lib/rumors/api/client/utils/list_articles.rb, line 10
def purify_gql_query
  gql_query.strip
end
variables() click to toggle source
# File lib/rumors/api/client/utils/list_articles.rb, line 14
def variables
  { text: @text.to_s }
end

Private Instance Methods

gql_query() click to toggle source
# File lib/rumors/api/client/utils/list_articles.rb, line 20
          def gql_query
            <<~GQL
            query($text: String) {
              ListArticles(
                filter: { moreLikeThis: { like: $text } }
                orderBy: [{ _score: DESC }]
                first: 4
              ) {
                edges {
                  node {
                    id
                    text
                    hyperlinks {
                      url
                    }
                    articleReplies {
                      reply {
                        id
                        text
                        type
                        reference
                      }
                    }
                  }
                }
              }
            }
            GQL
          end