Skip to content

Commit

Permalink
Working toward including response in GraphQL
Browse files Browse the repository at this point in the history
GraphQL

GraphQL
  • Loading branch information
matt-bernhardt committed Sep 26, 2024
1 parent 14858ad commit 10e4160
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/graphql/types/categories_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module Types
class CategoriesType < Types::BaseObject
description 'Information about one category linked to this search term'

field :confidence, Float, null: false, description: 'The application\'s confidence that the term belongs to this category - measured from 0.0 to 1.0'
field :name, String, null: false, description: 'The name of this category'

def name
@object.category.name
end
end
end
5 changes: 5 additions & 0 deletions app/graphql/types/search_event_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module Types
class SearchEventType < Types::BaseObject
field :categories, [Types::CategoriesType], description: 'The list of categories linked to term provided in this search'
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
field :detectors, Types::DetectorsType
field :id, ID, null: false
Expand All @@ -14,6 +15,10 @@ def phrase
@object.term.phrase
end

def categories
@object.term.categorizations
end

def detectors
@object.term.phrase
end
Expand Down
5 changes: 5 additions & 0 deletions app/graphql/types/term_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module Types
class TermType < Types::BaseObject
field :categories, [Types::CategoriesType], description: 'The list of categories linked to this term'
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
field :detectors, Types::DetectorsType
field :id, ID, null: false
Expand All @@ -14,6 +15,10 @@ def occurence_count
@object.search_events.count
end

def categories
@object.categorizations
end

def detectors
@object.phrase
end
Expand Down

0 comments on commit 10e4160

Please sign in to comment.