Skip to content

Commit

Permalink
feat(graphql): return userValue for message attachment doc
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Zhang <[email protected]>
  • Loading branch information
zwpaper committed Dec 9, 2024
1 parent 24ae8d8 commit 0a4bbdb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
5 changes: 3 additions & 2 deletions ee/tabby-schema/src/dao.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use tabby_db::{

use crate::{
integration::{Integration, IntegrationKind, IntegrationStatus},
interface::UserValue,
repository::RepositoryKind,
schema::{
auth::{self, OAuthCredential, OAuthProvider},
Expand Down Expand Up @@ -242,7 +243,7 @@ impl From<ThreadMessageAttachmentDoc> for thread::MessageAttachmentDoc {
thread::MessageAttachmentDoc::Issue(thread::MessageAttachmentIssueDoc {
title: val.title,
link: val.link,
author: val.author_user_id.map(|x| thread::MessageAttachmentAuthor {
author: val.author_user_id.map(|x| UserValue {
id: x,
email: None,
name: None,
Expand All @@ -255,7 +256,7 @@ impl From<ThreadMessageAttachmentDoc> for thread::MessageAttachmentDoc {
thread::MessageAttachmentDoc::Pull(thread::MessageAttachmentPullDoc {
title: val.title,
link: val.link,
author: val.author_user_id.map(|x| thread::MessageAttachmentAuthor {
author: val.author_user_id.map(|x| UserValue {
id: x,
email: None,
name: None,
Expand Down
2 changes: 1 addition & 1 deletion ee/tabby-schema/src/schema/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl JWTPayload {
}
}

#[derive(Debug, GraphQLObject)]
#[derive(Debug, GraphQLObject, Clone)]
#[graphql(context = Context, impl = [UserValue])]
pub struct UserSecured {
// === implements User ===
Expand Down
20 changes: 10 additions & 10 deletions ee/tabby-schema/src/schema/thread/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use tabby_common::api::{
};
use validator::Validate;

use crate::{juniper::relay::NodeType, Context};
use crate::{interface::UserValue, juniper::relay::NodeType, Context};

#[derive(GraphQLEnum, Serialize, Clone, PartialEq, Eq)]
pub enum Role {
Expand Down Expand Up @@ -55,6 +55,7 @@ pub struct UpdateMessageInput {
}

#[derive(GraphQLObject, Clone, Default)]
#[graphql(context = Context)]
pub struct MessageAttachment {
pub code: Vec<MessageAttachmentCode>,
pub client_code: Vec<MessageAttachmentClientCode>,
Expand Down Expand Up @@ -122,6 +123,7 @@ impl From<CodeSearchHit> for MessageCodeSearchHit {
}

#[derive(GraphQLUnion, Clone)]
#[graphql(context = Context)]
pub enum MessageAttachmentDoc {
Web(MessageAttachmentWebDoc),
Issue(MessageAttachmentIssueDoc),
Expand All @@ -136,26 +138,21 @@ pub struct MessageAttachmentWebDoc {
}

#[derive(GraphQLObject, Clone)]
#[graphql(context = Context)]
pub struct MessageAttachmentIssueDoc {
pub title: String,
pub link: String,
pub author: Option<MessageAttachmentAuthor>,
pub author: Option<UserValue>,
pub body: String,
pub closed: bool,
}

#[derive(GraphQLObject, Clone)]
pub struct MessageAttachmentAuthor {
pub id: String,
pub email: Option<String>,
pub name: Option<String>,
}

#[derive(GraphQLObject, Clone)]
#[graphql(context = Context)]
pub struct MessageAttachmentPullDoc {
pub title: String,
pub link: String,
pub author: Option<MessageAttachmentAuthor>,
pub author: Option<UserValue>,
pub body: String,
pub patch: String,
pub merged: bool,
Expand Down Expand Up @@ -191,6 +188,7 @@ impl From<DocSearchDocument> for MessageAttachmentDoc {
}

#[derive(GraphQLObject)]
#[graphql(context = Context)]
pub struct MessageDocSearchHit {
pub doc: MessageAttachmentDoc,
pub score: f64,
Expand Down Expand Up @@ -256,6 +254,7 @@ pub struct ThreadAssistantMessageAttachmentsCode {
}

#[derive(GraphQLObject)]
#[graphql(context = Context)]
pub struct ThreadAssistantMessageAttachmentsDoc {
pub hits: Vec<MessageDocSearchHit>,
}
Expand All @@ -274,6 +273,7 @@ pub struct ThreadAssistantMessageCompleted {
///
/// Apart from `thread_message_content_delta`, all other items will only appear once in the stream.
#[derive(GraphQLUnion)]
#[graphql(context = Context)]
pub enum ThreadRunItem {
ThreadCreated(ThreadCreated),
ThreadRelevantQuestions(ThreadRelevantQuestions),
Expand Down

0 comments on commit 0a4bbdb

Please sign in to comment.