Skip to content

Commit

Permalink
List TiplineMessage's by UID
Browse files Browse the repository at this point in the history
Add GraphQL type for `TiplineMessage` and list tipline messages by UID in `TeamType`.

Reference: CV2-3681.
  • Loading branch information
melsawy authored Sep 28, 2023
1 parent 11879ca commit 1ce2528
Show file tree
Hide file tree
Showing 5 changed files with 607 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/graph/types/team_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,12 @@ def shared_teams
field :feeds, FeedType.connection_type, null: true
field :tipline_newsletters, TiplineNewsletterType.connection_type, null: true
field :tipline_resources, TiplineResourceType.connection_type, null: true

field :tipline_messages, TiplineMessageType.connection_type, null: true do
argument :uid, GraphQL::Types::String, required: true
end

def tipline_messages(uid:)
object.tipline_messages.where(uid: uid).last(100)
end
end
22 changes: 22 additions & 0 deletions app/graph/types/tipline_message_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class TiplineMessageType < DefaultObject
description "TiplineMessage type"

implements GraphQL::Types::Relay::Node

field :dbid, GraphQL::Types::Int, null: true
field :event, GraphQL::Types::String, null: true
field :direction, GraphQL::Types::String, null: true
field :language, GraphQL::Types::String, null: true
field :platform, GraphQL::Types::String, null: true
field :uid, GraphQL::Types::String, null: true
field :external_id, GraphQL::Types::String, null: true
field :payload, JsonStringType, null: true
field :team_id, GraphQL::Types::Int, null: true
field :state, GraphQL::Types::String, null: true
field :team, TeamType, null: true
field :sent_at, GraphQL::Types::String, null: true, camelize: false

def sent_at
object.sent_at.to_i.to_s
end
end
80 changes: 80 additions & 0 deletions lib/relay.idl
Original file line number Diff line number Diff line change
Expand Up @@ -12866,6 +12866,28 @@ type Team implements Node {
last: Int
status: [String]
): TeamUserConnection
tipline_messages(
"""
Returns the elements in the list that come after the specified cursor.
"""
after: String

"""
Returns the elements in the list that come before the specified cursor.
"""
before: String

"""
Returns the first _n_ elements from the list.
"""
first: Int

"""
Returns the last _n_ elements from the list.
"""
last: Int
uid: String!
): TiplineMessageConnection
tipline_newsletters(
"""
Returns the elements in the list that come after the specified cursor.
Expand Down Expand Up @@ -13142,6 +13164,64 @@ type TeamUserEdge {
node: TeamUser
}

"""
TiplineMessage type
"""
type TiplineMessage implements Node {
created_at: String
dbid: Int
direction: String
event: String
external_id: String
id: ID!
language: String
payload: JsonStringType
permissions: String
platform: String
sent_at: String
state: String
team: Team
team_id: Int
uid: String
updated_at: String
}

"""
The connection type for TiplineMessage.
"""
type TiplineMessageConnection {
"""
A list of edges.
"""
edges: [TiplineMessageEdge]

"""
A list of nodes.
"""
nodes: [TiplineMessage]

"""
Information to aid in pagination.
"""
pageInfo: PageInfo!
totalCount: Int
}

"""
An edge in a connection.
"""
type TiplineMessageEdge {
"""
A cursor for use in pagination.
"""
cursor: String!

"""
The item at the end of the edge.
"""
node: TiplineMessage
}

"""
TiplineNewsletter type
"""
Expand Down
Loading

0 comments on commit 1ce2528

Please sign in to comment.