This repository has been archived by the owner on May 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add `repo` sub command. - Show repo basic info as the inital functionality. - Use the GH graphql api. - Add `graphql_client` crate. - Add `graphql` queries directory in the root with the basic_info query. - Include files generated using `graphql-client` CLI. This need to be part of a `build.rs` for later.
- Loading branch information
Showing
13 changed files
with
459 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
/target | ||
SECRET.txt | ||
graphql/schema/ | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ sodiumoxide = "0.2.5" | |
base64 = "0.12.0" | ||
async-trait = "0.1.30" | ||
ansi_term = "0.12.1" | ||
graphql_client = "0.9.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
query RepoBasicInfoQuery($name: String!, $owner: String!) { | ||
repository(name: $name, owner: $owner) { | ||
nameWithOwner | ||
description | ||
createdAt | ||
pushedAt | ||
homepageUrl | ||
isPrivate | ||
isArchived | ||
primaryLanguage { | ||
name | ||
} | ||
licenseInfo { | ||
name | ||
} | ||
stargazers { | ||
totalCount | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use super::repos::{Repo, RepoRequest}; | ||
pub use crate::graphql::repo_basic_info::repo_basic_info_query as basic_info_response; | ||
use crate::{graphql::repo_basic_info::RepoBasicInfoQuery, utils::graphql::query_graphql}; | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use graphql_client::GraphQLQuery as _; | ||
|
||
pub type BasicInfoResponse = basic_info_response::ResponseData; | ||
|
||
#[async_trait] | ||
pub trait BasicInfo { | ||
async fn get_basic_info(&self) -> Result<BasicInfoResponse>; | ||
} | ||
|
||
impl From<&Repo<'_>> for basic_info_response::Variables { | ||
fn from(repo: &Repo<'_>) -> Self { | ||
basic_info_response::Variables { | ||
name: repo.repo_name.to_owned(), | ||
owner: repo.repo_owner.to_owned(), | ||
} | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl BasicInfo for RepoRequest<'_> { | ||
async fn get_basic_info(&self) -> Result<BasicInfoResponse> { | ||
let RepoRequest(repo, auth_token) = self; | ||
let graphql_query = RepoBasicInfoQuery::build_query(repo.into()); | ||
let resp = query_graphql(graphql_query, &auth_token).await?; | ||
resp.data | ||
.ok_or_else(|| anyhow::anyhow!("Couldn't find repository basic information!")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod basic_info; | ||
pub mod repos; | ||
pub mod secrets; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod repo_basic_info; |
Oops, something went wrong.