MCPcopy Create free account
hub / github.com/emwalker/digraph / repos

Method repos

backend/src/graphql/user.rs:61–110  ·  view source on GitHub ↗
(
        &self,
        ctx: &Context<'_>,
        after: Option<String>,
        before: Option<String>,
        first: Option<i32>,
        last: Option<i32>,
    )

Source from the content-addressed store, hash-verified

59 }
60
61 pub async fn repos(
62 &self,
63 ctx: &Context<'_>,
64 after: Option<String>,
65 before: Option<String>,
66 first: Option<i32>,
67 last: Option<i32>,
68 ) -> Result<RepositoryConnection> {
69 let (selected_repo_id, results) = match self {
70 Self::Guest => (ID("".into()), vec![]),
71 Self::Registered {
72 id,
73 selected_repo_id,
74 ..
75 } => {
76 let results = ctx
77 .data_unchecked::<Store>()
78 .repositories_for_user(id.to_string())
79 .await?;
80 (selected_repo_id.clone().unwrap_or_default(), results)
81 }
82 };
83
84 query(
85 after,
86 before,
87 first,
88 last,
89 |_after, _before, _first, _last| async move {
90 let mut connection = Connection::new(false, false);
91 connection.edges.extend(results.into_iter().map(|n| {
92 let repo_id = match &n {
93 Repository::Default => ID("".to_string()),
94 Repository::Fetched { id, .. } => ID(id.clone()),
95 };
96
97 Edge::with_additional_fields(
98 0_usize,
99 n,
100 RepositoryEdgeFields {
101 is_selected: repo_id == selected_repo_id,
102 },
103 )
104 }));
105 Ok::<_, Error>(connection)
106 },
107 )
108 .await
109 .map_err(Error::from)
110 }
111
112 pub async fn selected_repo(&self, ctx: &Context<'_>) -> Result<Option<Repository>> {
113 match self {

Callers

nothing calls this directly

Calls 2

IDFunction · 0.85
repositories_for_userMethod · 0.80

Tested by

no test coverage detected