Skip to content
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
348 changes: 20 additions & 328 deletions Cargo.lock

Large diffs are not rendered by default.

139 changes: 71 additions & 68 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ http = "0.2.12" # previous version until hyper is updated to 1+
insta = { version = "1.38.0", features = ["json"] }
tokio = { version = "1.37.0", features = ["rt", "time"] }
reqwest = { version = "0.11", features = [
"json",
"rustls-tls",
"json",
"rustls-tls",
], default-features = false }
tracing = "0.1.40"
lazy_static = "1.4.0"
Expand All @@ -36,23 +36,23 @@ tailcall-valid = "0.1.1"

mimalloc = { version = "0.1.41", default-features = false, optional = true }
http-cache-reqwest = { version = "0.13.0", features = [
"manager-moka",
"manager-moka",
], default-features = false, optional = true }
moka = { version = "0.12.7", default-features = false, features = [
"future",
"future",
], optional = true }
hyper-rustls = { version = "0.25.0", optional = true }
rustls = { version = "0.23.5", optional = true, features = [
"std",
"std",
], default-features = false }
rustls-pki-types = "1.5.0"
inquire = { version = "0.7.5", optional = true }
opentelemetry-otlp = { version = "0.16.0", features = [
"trace",
"logs",
"metrics",
# required to make grpc requests
"tls-roots",
"trace",
"logs",
"metrics",
# required to make grpc requests
"tls-roots",
], optional = true }
opentelemetry-system-metrics = { version = "0.2.0", optional = true }
tailcall-http-cache = { path = "tailcall-http-cache", optional = true }
Expand Down Expand Up @@ -96,17 +96,17 @@ futures-timer = { version = "3.0.3", features = ["wasm-bindgen"] }
futures-util = { workspace = true }
lru = { version = "0.12.3" }
async-std = { version = "1.12.0", features = [
"wasm-bindgen-futures",
"unstable",
"wasm-bindgen-futures",
"unstable",
] }
ttl_cache = "0.5.1"
protox = "0.7.0"
protox-parse = "0.7.0"
prost-reflect = { version = "0.14.0", features = ["serde"] }
prost = "0.13.1"
update-informer = { version = "1.1.0", default-features = false, features = [
"github",
"reqwest",
"github",
"reqwest",
], optional = true }
lazy_static = { workspace = true }
which = { version = "7.0.0", optional = true }
Expand All @@ -116,9 +116,9 @@ strum_macros = "0.26.4"
# TODO: disable some levels with features?
tracing = { workspace = true }
tracing-subscriber = { version = "0.3.18", features = [
"default",
"fmt",
"env-filter",
"default",
"fmt",
"env-filter",
] }
tracing-opentelemetry = "0.24.0"
getrandom = { version = "0.2.14", features = ["js"] }
Expand All @@ -127,32 +127,32 @@ tonic = { version = "0.11.0", default-features = false }
opentelemetry-semantic-conventions = "0.15.0"
opentelemetry = { version = "0.23.0", features = ["trace", "logs", "metrics"] }
opentelemetry_sdk = { version = "0.23.0", features = [
"trace",
"logs",
"metrics",
"trace",
"logs",
"metrics",
] }
opentelemetry-http = "0.12.0"
opentelemetry-stdout = { version = "0.4.0", features = [
"trace",
"logs",
"metrics",
"trace",
"logs",
"metrics",
] }
opentelemetry-appender-tracing = { version = "0.4.0" }
opentelemetry-prometheus = "0.16.0"
phonenumber = "0.3.4"
chrono = "0.4.38"
async-graphql-extension-apollo-tracing = { version = "3.2.15"}
# async-graphql-extension-apollo-tracing = { version = "3.2.15" }
headers = { workspace = true }
http = { workspace = true }
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.9"
async-graphql = { workspace = true, features = [
"dynamic-schema",
"dataloader",
"apollo_tracing",
"opentelemetry",
"dynamic-schema",
"dataloader",
"apollo_tracing",
"opentelemetry",
] }
dotenvy = "0.15.7"
convert_case = { workspace = true }
Expand All @@ -179,7 +179,10 @@ unicode-segmentation = "1.12.0"

# to build rquickjs bindings on systems without builtin bindings
[target.'cfg(all(target_os = "windows", target_arch = "x86"))'.dependencies]
rquickjs = { "version" = "0.7.0", optional = true, features = ["macro", "bindgen"] }
rquickjs = { "version" = "0.7.0", optional = true, features = [
"macro",
"bindgen",
] }

[dev-dependencies]
datatest-stable = "0.2.9"
Expand All @@ -195,16 +198,16 @@ tempfile = "3.10.1"
maplit = "1.0.2"
tailcall-fixtures = { path = "./tailcall-fixtures" }
http-cache-semantics = { version = "1.0.1", default-features = false, features = [
"with_serde",
"reqwest",
"with_serde",
"reqwest",
] }
cacache = { version = "13.0.0", default-features = false, features = [
"tokio-runtime",
"mmap",
"tokio-runtime",
"mmap",
] }
test-log = { version = "0.2.16", default-features = false, features = [
"color",
"trace",
"color",
"trace",
] }
flate2 = "1.0.30"
bincode = "1.3.3"
Expand All @@ -219,25 +222,25 @@ js = ["dep:rquickjs"]
# This is created to control what we expose for WASM.
# Will be deprecated once we move CLI to it's own crate and WASM builds won't depend on it.
cli = [
"tokio/fs",
"tokio/rt-multi-thread",
"dep:mimalloc",
"dep:http-cache-reqwest",
"dep:moka",
"dep:hyper-rustls",
"dep:rustls",
"dep:inquire",
"dep:which",
"dep:update-informer",
"opentelemetry_sdk/testing",
"opentelemetry_sdk/rt-tokio",
"dep:opentelemetry-otlp",
"dep:opentelemetry-system-metrics",
"dep:tailcall-tracker",
"dep:tailcall-http-cache",
"dep:tailcall-version",
"dep:genai",
"dep:ctrlc",
"tokio/fs",
"tokio/rt-multi-thread",
"dep:mimalloc",
"dep:http-cache-reqwest",
"dep:moka",
"dep:hyper-rustls",
"dep:rustls",
"dep:inquire",
"dep:which",
"dep:update-informer",
"opentelemetry_sdk/testing",
"opentelemetry_sdk/rt-tokio",
"dep:opentelemetry-otlp",
"dep:opentelemetry-system-metrics",
"dep:tailcall-tracker",
"dep:tailcall-http-cache",
"dep:tailcall-version",
"dep:genai",
"dep:ctrlc",
]

# Feature flag to enable all default features.
Expand All @@ -250,20 +253,20 @@ force_jit = []

[workspace]
members = [
".",
"tailcall-typedefs-common",
"tailcall-typedefs",
"tailcall-aws-lambda",
"tailcall-cloudflare",
"tailcall-macros",
"tailcall-prettier",
"tailcall-fixtures",
"tailcall-upstream-grpc",
"tailcall-tracker",
"tailcall-wasm",
"tailcall-hasher",
"tailcall-http-cache",
"tailcall-version",
".",
"tailcall-typedefs-common",
"tailcall-typedefs",
"tailcall-aws-lambda",
"tailcall-cloudflare",
"tailcall-macros",
"tailcall-prettier",
"tailcall-fixtures",
"tailcall-upstream-grpc",
"tailcall-tracker",
"tailcall-wasm",
"tailcall-hasher",
"tailcall-http-cache",
"tailcall-version",
]

# Boost execution_spec snapshot diffing performance
Expand Down
22 changes: 11 additions & 11 deletions src/cli/server/server_config.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::sync::Arc;

Check warning on line 2 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/cli/server/server_config.rs

use async_graphql_extension_apollo_tracing::ApolloTracing;
// use async_graphql_extension_apollo_tracing::ApolloTracing;

use crate::cli::runtime::init;
use crate::core::app_context::AppContext;
use crate::core::blueprint::telemetry::TelemetryExporter;

Check failure on line 8 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Check Examples

unused import: `crate::core::blueprint::telemetry::TelemetryExporter`

Check failure on line 8 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

unused import: `crate::core::blueprint::telemetry::TelemetryExporter`

Check failure on line 8 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

unused import: `crate::core::blueprint::telemetry::TelemetryExporter`

Check failure on line 8 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

unused import: `crate::core::blueprint::telemetry::TelemetryExporter`

Check failure on line 8 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

unused import: `crate::core::blueprint::telemetry::TelemetryExporter`

Check failure on line 8 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

unused import: `crate::core::blueprint::telemetry::TelemetryExporter`

Check failure on line 8 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

unused import: `crate::core::blueprint::telemetry::TelemetryExporter`

Check failure on line 8 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

unused import: `crate::core::blueprint::telemetry::TelemetryExporter`

Check failure on line 8 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

unused import: `crate::core::blueprint::telemetry::TelemetryExporter`

Check failure on line 8 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

unused import: `crate::core::blueprint::telemetry::TelemetryExporter`
use crate::core::blueprint::{Blueprint, Http};
use crate::core::rest::{EndpointSet, Unchecked};
use crate::core::schema_extension::SchemaExtension;

Check failure on line 11 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Check Examples

unused import: `crate::core::schema_extension::SchemaExtension`

Check failure on line 11 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

unused import: `crate::core::schema_extension::SchemaExtension`

Check failure on line 11 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

unused import: `crate::core::schema_extension::SchemaExtension`

Check failure on line 11 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

unused import: `crate::core::schema_extension::SchemaExtension`

Check failure on line 11 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

unused import: `crate::core::schema_extension::SchemaExtension`

Check failure on line 11 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

unused import: `crate::core::schema_extension::SchemaExtension`

Check failure on line 11 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

unused import: `crate::core::schema_extension::SchemaExtension`

Check failure on line 11 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

unused import: `crate::core::schema_extension::SchemaExtension`

Check failure on line 11 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

unused import: `crate::core::schema_extension::SchemaExtension`

Check failure on line 11 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

unused import: `crate::core::schema_extension::SchemaExtension`

pub struct ServerConfig {
pub blueprint: Blueprint,
Expand All @@ -21,19 +21,19 @@
endpoints: EndpointSet<Unchecked>,
) -> anyhow::Result<Self> {
let mut rt = init(&blueprint);

Check warning on line 24 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/cli/server/server_config.rs
let mut extensions = vec![];

Check failure on line 25 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Check Examples

variable does not need to be mutable

Check failure on line 25 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

variable does not need to be mutable

Check failure on line 25 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

variable does not need to be mutable

Check failure on line 25 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

variable does not need to be mutable

Check failure on line 25 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

variable does not need to be mutable

Check failure on line 25 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

variable does not need to be mutable

Check failure on line 25 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

variable does not need to be mutable

Check failure on line 25 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

variable does not need to be mutable

Check failure on line 25 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

variable does not need to be mutable

Check failure on line 25 in src/cli/server/server_config.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

variable does not need to be mutable

if let Some(TelemetryExporter::Apollo(apollo)) = blueprint.telemetry.export.as_ref() {
let (graph_id, variant) = apollo.graph_ref.split_once('@').unwrap();
extensions.push(SchemaExtension::new(ApolloTracing::new(
apollo.api_key.clone(),
apollo.platform.clone().unwrap_or_default(),
graph_id.to_string(),
variant.to_string(),
apollo.version.clone().unwrap_or_default(),
)));
}
// if let Some(TelemetryExporter::Apollo(apollo)) = blueprint.telemetry.export.as_ref() {
// let (graph_id, variant) = apollo.graph_ref.split_once('@').unwrap();
// extensions.push(SchemaExtension::new(ApolloTracing::new(
// apollo.api_key.clone(),
// apollo.platform.clone().unwrap_or_default(),
// graph_id.to_string(),
// variant.to_string(),
// apollo.version.clone().unwrap_or_default(),
// )));
// }
rt.add_extensions(extensions);

let endpoints = endpoints.into_checked(&blueprint, rt.clone()).await?;
Expand Down
21 changes: 15 additions & 6 deletions src/core/jit/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,11 @@ impl<'a> Builder<'a> {
}

#[inline(always)]
pub fn build(&self, operation_name: Option<&str>) -> Result<OperationPlan<Value>, BuildError> {
pub fn build(
&self,
operation_name: Option<&str>,
variables: Variables<Value>,
) -> Result<OperationPlan<Value>, BuildError> {
let mut fragments: HashMap<&str, &FragmentDefinition> = HashMap::new();

for (name, fragment) in self.document.fragments.iter() {
Expand Down Expand Up @@ -379,6 +383,7 @@ impl<'a> Builder<'a> {
self.index.clone(),
is_introspection_query,
Some(self.index.get_interfaces()),
variables,
);
Ok(plan)
}
Expand All @@ -400,7 +405,9 @@ mod tests {
let config = Config::from_sdl(CONFIG).to_result().unwrap();
let blueprint = Blueprint::try_from(&config.into()).unwrap();
let document = async_graphql::parser::parse_query(query).unwrap();
Builder::new(&blueprint, &document).build(None).unwrap()
Builder::new(&blueprint, &document)
.build(None, Variables::new())
.unwrap()
}

#[tokio::test]
Expand Down Expand Up @@ -668,24 +675,26 @@ mod tests {
let config = Config::from_sdl(CONFIG).to_result().unwrap();
let blueprint = Blueprint::try_from(&config.into()).unwrap();
let document = async_graphql::parser::parse_query(query).unwrap();
let error = Builder::new(&blueprint, &document).build(None).unwrap_err();
let error = Builder::new(&blueprint, &document)
.build(None, Variables::new())
.unwrap_err();

assert_eq!(error, BuildError::OperationNameRequired);

let error = Builder::new(&blueprint, &document)
.build(Some("unknown"))
.build(Some("unknown"), Variables::new())
.unwrap_err();

assert_eq!(error, BuildError::OperationNotFound("unknown".to_string()));

let plan = Builder::new(&blueprint, &document)
.build(Some("GetPosts"))
.build(Some("GetPosts"), Variables::new())
.unwrap();
assert!(plan.is_query());
insta::assert_debug_snapshot!(plan.selection);

let plan = Builder::new(&blueprint, &document)
.build(Some("CreateNewPost"))
.build(Some("CreateNewPost"), Variables::new())
.unwrap();
assert!(!plan.is_query());
insta::assert_debug_snapshot!(plan.selection);
Expand Down
10 changes: 8 additions & 2 deletions src/core/jit/fixtures/jp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,14 @@ impl<'a, Value: Deserialize<'a> + Clone + 'a + JsonLike<'a> + std::fmt::Debug> J
let config = ConfigModule::from(Config::from_sdl(Self::CONFIG).to_result().unwrap());
let doc = async_graphql::parser::parse_query(query).unwrap();
let builder = Builder::new(&Blueprint::try_from(&config).unwrap(), &doc);

let plan = builder.build(None).unwrap();
let v: Variables<async_graphql_value::Value> = Variables::from_iter(
variables
.clone()
.into_hashmap()
.into_iter()
.map(|(k, v)| (k, v.into())),
);
let plan = builder.build(None, v).unwrap();
let plan = transform::Skip::new(variables)
.transform(plan)
.to_result()
Expand Down
1 change: 1 addition & 0 deletions src/core/jit/graphql_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ impl JITExecutor {
fn req_hash(request: &async_graphql::Request) -> OPHash {
let mut hasher = TailcallHasher::default();
request.query.hash(&mut hasher);
request.variables.to_string().hash(&mut hasher);

OPHash::new(hasher.finish())
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/jit/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ pub struct OperationPlan<Input> {
pub selection: Vec<Field<Input>>,
pub before: Option<IR>,
pub interfaces: Option<HashSet<String>>,
pub variables: Variables<Input>,
}

impl<Input> OperationPlan<Input> {
Expand All @@ -343,6 +344,7 @@ impl<Input> OperationPlan<Input> {
min_cache_ttl: self.min_cache_ttl,
before: self.before,
interfaces: None,
variables: self.variables.try_map(&map)?,
})
}
}
Expand All @@ -356,6 +358,7 @@ impl<Input> OperationPlan<Input> {
index: Arc<Index>,
is_introspection_query: bool,
interfaces: Option<HashSet<String>>,
variables: Variables<Input>,
) -> Self
where
Input: Clone,
Expand All @@ -372,6 +375,7 @@ impl<Input> OperationPlan<Input> {
min_cache_ttl: None,
before: Default::default(),
interfaces,
variables,
}
}

Expand Down
Loading
Loading