Skip to content

Commit

Permalink
CV2-3777: add smooch_request_type field
Browse files Browse the repository at this point in the history
  • Loading branch information
melsawy committed Oct 19, 2023
1 parent 77ff15e commit 575e970
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
13 changes: 0 additions & 13 deletions app/graph/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,6 @@ def dynamic_annotation_field(query:, only_cache: nil)
end
end

field :tipline_request,
TiplineRequestType,
description:
"Information about tipline request, given its id",
null: true do
argument :id, GraphQL::Types::String, required: true
end

def tipline_request(id:)
ability = context[:ability] || Ability.new
DynamicAnnotation::Field.find_by_id(id.to_i) if ability.can?(:find_by_json_fields, DynamicAnnotation::Field.new)
end

# Getters by ID
%i[
source
Expand Down
1 change: 1 addition & 0 deletions app/graph/types/tipline_request_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ class TiplineRequestType < DefaultObject
field :smooch_user_request_language, GraphQL::Types::String, null: true
field :smooch_report_sent_at, GraphQL::Types::Int, null: true
field :smooch_report_correction_sent_at, GraphQL::Types::Int, null: true
field :smooch_request_type, GraphQL::Types::String, null: true
end
6 changes: 6 additions & 0 deletions app/models/concerns/smooch_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ def smooch_report_correction_sent_at
end
end

def smooch_request_type
Concurrent::Future.execute(executor: CheckGraphql::POOL) do
begin self.annotation.load.get_field_value('smooch_request_type') rescue nil end
end
end

def smooch_user_request_language
Concurrent::Future.execute(executor: CheckGraphql::POOL) do
return '' unless self.field_name == 'smooch_data'
Expand Down
5 changes: 3 additions & 2 deletions lib/relay.idl
Original file line number Diff line number Diff line change
Expand Up @@ -11753,9 +11753,9 @@ type Query {
team(id: ID, random: String, slug: String): Team

"""
Information about tipline request, given its id
Information about the tipline_message with given id
"""
tipline_request(id: String!): TiplineRequest
tipline_message(id: ID!): TiplineMessage

"""
Information about the user with given id
Expand Down Expand Up @@ -13532,6 +13532,7 @@ type TiplineRequest implements Node {
smooch_report_received_at: Int
smooch_report_sent_at: Int
smooch_report_update_received_at: Int
smooch_request_type: String
smooch_user_external_identifier: String
smooch_user_request_language: String
smooch_user_slack_channel_url: String
Expand Down
22 changes: 18 additions & 4 deletions public/relay.json
Original file line number Diff line number Diff line change
Expand Up @@ -61864,8 +61864,8 @@
"deprecationReason": null
},
{
"name": "tipline_request",
"description": "Information about tipline request, given its id",
"name": "tipline_message",
"description": "Information about the tipline_message with given id",
"args": [
{
"name": "id",
Expand All @@ -61875,7 +61875,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"name": "ID",
"ofType": null
}
},
Expand All @@ -61886,7 +61886,7 @@
],
"type": {
"kind": "OBJECT",
"name": "TiplineRequest",
"name": "TiplineMessage",
"ofType": null
},
"isDeprecated": false,
Expand Down Expand Up @@ -71075,6 +71075,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "smooch_request_type",
"description": null,
"args": [

],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "smooch_user_external_identifier",
"description": null,
Expand Down

0 comments on commit 575e970

Please sign in to comment.