15 releases
0.1.16 | Nov 9, 2022 |
---|---|
0.1.14 | Nov 7, 2022 |
#1598 in Development tools
Used in test-shisho-gql-derive
180KB
5K
SLoC
Shisho Policy Rust SDK
This is a helper crate for Shisho Cloud workflows to write custom policies.
This is the core library to write custom policies.
decision
includes the structs ofoutput data
(=decsion
results).gqlgen
includes the functionalities of converting fromgeraphql
schema and queries. The original code comes fromgraphql-client/graphql_client_codegen
schema
includes the string ofdatasource
graphql query. The schema is generated by the codegen.
Required crate
This required the helper crate, shisho-gql-derive
Example usage
use shisho_gql_derive::*;
pub use shisho_policy_sdk::decision::data_entry::*;
pub use shisho_policy_sdk::decision::github::organization::org_owners::*;
pub use shisho_policy_sdk::decision::*;
use self::input::InputGithubOrganizations;
#[allow(dead_code)]
#[derive(ShishoGraphQLQuery)]
#[shisho_graphql(
query_path = "src/policies/organization/org_owners/query.graphql",
response_derives = "Debug, PartialEq"
)]
pub struct Input;
pub fn decisions(input: input::InputData) -> Vec<Decision<OrgOwnersEntryData>> {
input
.github
.organizations
.into_iter()
.map(|o: InputGithubOrganizations| decide_on_each_org(o))
.collect()
}
pub fn decide_on_each_org(o: InputGithubOrganizations) -> Decision<OrgOwnersEntryData> {
...
}
Reference
graphql-client/graphql_client_codegen
- refer the static string of the Shisho Cloud GraphQL schema instead of the argument reference
Dependencies
~1.7–2.6MB
~57K SLoC