Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: impl from document query bp #2092

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,11 @@ jobs:
run: |
wrk -d 30 -t 4 -c 100 -s wrk.lua http://localhost:8000/graphql > wrk-output.txt

- id: convert_wrk_output_json
name: Convert Output to JSON
working-directory: ci-benchmark
run: |
node wrk-output-to-json.js wrk-output.txt > results.json

- id: push_to_bencher
working-directory: ci-benchmark
uses: bencherdev/bencher@main
run: |
bencher run \
--project tailcall \
--token '${{ secrets.BENCHER_API_TOKEN }}' \
--branch '${{ github.head_ref }}' \
--branch-start-point '${{ github.base_ref }}' \
--branch-start-point-hash '${{ github.base_sha }}' \
--testbed ubuntu-latest \
--adapter json \
--err \
--file "results.json"
--github-actions '${{ secrets.GITHUB_TOKEN }}' \

- id: convert_wrk_output_markdown
name: Convert Output to Markdown
working-directory: ci-benchmark
run: |
node wrk-output-to-md.js wrk-output.txt > body.md

- id: cat_md
name: Cat Markdown
working-directory: ci-benchmark
Expand Down
33 changes: 14 additions & 19 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ tailcall-version = { path = "./tailcall-version", optional = true }
# dependencies safe for wasm:

rustls-pemfile = { version = "1.0.4" }
schemars = { version = "0.8.17", features = ["derive"] }
schemars = { version = "0.8.21", features = ["derive"] }
hyper = { version = "0.14.28", features = ["server"], default-features = false }
tokio = { workspace = true }
anyhow = { workspace = true }
Expand Down Expand Up @@ -141,6 +141,7 @@ mime = "0.3.17"
htpasswd-verify = { version = "0.3.0", git = "https://github.com/twistedfall/htpasswd-verify", rev = "ff14703083cbd639f7d05622b398926f3e718d61" } # fork version that is wasm compatible
jsonwebtoken = "9.3.0"
async-graphql-value = "7.0.3"
async-graphql-parser = "7.0.5"
async-graphql = { workspace = true, features = [
"dynamic-schema",
"dataloader",
Expand All @@ -157,7 +158,7 @@ datatest-stable = "0.2.9"
tokio-test = "0.4.4"
base64 = "0.22.1"
tailcall-hasher = { path = "tailcall-hasher" }
serde_json_borrow = "0.5.0"
serde_json_borrow = {git = "https://github.com/tailcallhq/serde_json_borrow", branch = "temp"}

[dev-dependencies]
tailcall-prettier = { path = "tailcall-prettier" }
Expand Down
39 changes: 0 additions & 39 deletions ci-benchmark/wrk-output-to-json.js

This file was deleted.

2 changes: 2 additions & 0 deletions generated/.tailcallrc.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@
},
"protected": {
"description": "Marks field as protected by auth provider",
"default": null,
"anyOf": [
{
"$ref": "#/definitions/Protected"
Expand Down Expand Up @@ -1266,6 +1267,7 @@
},
"protected": {
"description": "Marks field as protected by auth providers",
"default": null,
"anyOf": [
{
"$ref": "#/definitions/Protected"
Expand Down
7 changes: 4 additions & 3 deletions npm/package-lock.json

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

24 changes: 23 additions & 1 deletion src/core/blueprint/blueprint.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::{BTreeSet, HashMap};
use std::fmt::{Debug, Formatter};
use std::sync::Arc;

use async_graphql::dynamic::{Schema, SchemaBuilder};
Expand Down Expand Up @@ -27,12 +28,33 @@ pub struct Blueprint {
pub telemetry: Telemetry,
}

#[derive(Clone, Debug)]
#[derive(Clone)]
pub enum Type {
NamedType { name: String, non_null: bool },
ListType { of_type: Box<Type>, non_null: bool },
}

impl Debug for Type {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Type::NamedType { name, non_null } => {
if *non_null {
write!(f, "{}!", name)
} else {
write!(f, "{}", name)
}
}
Type::ListType { of_type, non_null } => {
if *non_null {
write!(f, "[{:?}]!", of_type)
} else {
write!(f, "[{:?}]", of_type)
}
}
}
}
}

impl Default for Type {
fn default() -> Self {
Type::NamedType { name: "JSON".to_string(), non_null: false }
Expand Down
24 changes: 1 addition & 23 deletions src/core/http/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use tonic_types::Status as GrpcStatus;

use crate::core::grpc::protobuf::ProtobufOperation;
use crate::core::ir::EvaluationError;
use crate::core::FromValue;

#[derive(Clone, Debug, Default, Setters)]
pub struct Response<Body> {
Expand All @@ -23,29 +24,6 @@ pub struct Response<Body> {
// efficient. Benchmarking is required to determine the performance If any
// change is made.

pub trait FromValue {
fn from_value(value: serde_json_borrow::Value) -> Self;
}

impl FromValue for ConstValue {
fn from_value(value: serde_json_borrow::Value) -> Self {
match value {
serde_json_borrow::Value::Null => ConstValue::Null,
serde_json_borrow::Value::Bool(b) => ConstValue::Boolean(b),
serde_json_borrow::Value::Number(n) => ConstValue::Number(n.into()),
serde_json_borrow::Value::Str(s) => ConstValue::String(s.into()),
serde_json_borrow::Value::Array(a) => {
ConstValue::List(a.into_iter().map(|v| Self::from_value(v)).collect())
}
serde_json_borrow::Value::Object(o) => ConstValue::Object(
o.iter()
.map(|(k, v)| (Name::new(k), Self::from_value(v.to_owned())))
.collect(),
),
}
}
}

impl Response<Bytes> {
pub async fn from_reqwest(resp: reqwest::Response) -> Result<Self> {
let status = resp.status();
Expand Down
Loading