Skip to content

Commit

Permalink
graphql client
Browse files Browse the repository at this point in the history
  • Loading branch information
j-white committed May 2, 2024
1 parent afa3a4a commit d6d9057
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
/node_modules
.env
.idea
145 changes: 137 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
graphql_client = "0.14.0"
serde = "1.0.200"
worker = "0.2.0"

[profile.release]
Expand Down
26 changes: 26 additions & 0 deletions gql/queries.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
query GetWorkersAnalytics($accountTag: string, $datetimeStart: string, $datetimeEnd: string, $scriptName: string) {
viewer {
accounts(filter: {accountTag: $accountTag}) {
workersInvocationsAdaptive(limit: 100, filter: {
scriptName: $scriptName,
datetime_geq: $datetimeStart,
datetime_leq: $datetimeEnd
}) {
sum {
subrequests
requests
errors
}
quantiles {
cpuTimeP50
cpuTimeP99
}
dimensions{
datetime
scriptName
status
}
}
}
}
}
22 changes: 22 additions & 0 deletions src/gql.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use graphql_client::GraphQLQuery;

// The paths are relative to the directory where your `Cargo.toml` is located.
// Both json and the GraphQL schema language are supported as sources for the schema
#[derive(GraphQLQuery)]
#[graphql(
schema_path = "gql/schema.graphql",
query_path = "gql/queries.graphql",
)]
pub struct GetWorkersAnalytics;

#[allow(non_camel_case_types)]
type float32 = f32;

#[allow(non_camel_case_types)]
type string = String;

#[allow(non_camel_case_types)]
type Time = String;

#[allow(non_camel_case_types)]
type uint64 = u64;
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
mod gql;

use worker::*;

#[event(fetch)]
async fn main(req: Request, env: Env, ctx: Context) -> Result<Response> {
async fn main(_req: Request, _env: Env, _ctx: Context) -> Result<Response> {
Response::ok("Hello, World!")
}

0 comments on commit d6d9057

Please sign in to comment.