Skip to content

Commit

Permalink
- handle batchKey with root resolvers only.
Browse files Browse the repository at this point in the history
  • Loading branch information
laststylebender14 committed Dec 9, 2024
1 parent bfb5572 commit 0c55ae2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/core/blueprint/operators/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub fn compile_http(
config_module: &config::ConfigModule,
http: &config::Http,
field: &Field,
container_type: &str,
) -> Valid<IR, BlueprintError> {
let is_list = field.type_of.is_list();
let dedupe = http.dedupe.unwrap_or_default();
Expand All @@ -26,7 +27,11 @@ pub fn compile_http(
.when(|| !http.batch_key.is_empty() && http.method != Method::GET)
.and(
Valid::<(), BlueprintError>::fail(BlueprintError::BatchKeyListConflict)
.when(|| !http.batch_key.is_empty() && is_list)
.when(|| {
!http.batch_key.is_empty()
&& is_list
&& config_module.is_root_operation_type(container_type)
})
.trace("batchKey"),
)
.and(
Expand Down
6 changes: 3 additions & 3 deletions src/core/blueprint/operators/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ pub fn compile_resolver(
inputs: &CompileResolver,

Check warning on line 18 in src/core/blueprint/operators/resolver.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/_work/tailcall/tailcall/src/core/blueprint/operators/resolver.rs
resolver: &Resolver,
) -> Valid<Option<IR>, BlueprintError> {
let CompileResolver { config_module, field, operation_type, object_name } = inputs;
let CompileResolver { config_module, field, operation_type, object_name: container_type } = inputs;

match resolver {
Resolver::Http(http) => {
compile_http(config_module, http, field).trace(config::Http::trace_name().as_str())
compile_http(config_module, http, field, container_type).trace(config::Http::trace_name().as_str())
}
Resolver::Grpc(grpc) => compile_grpc(super::CompileGrpc {
config_module,
Expand All @@ -36,7 +36,7 @@ pub fn compile_resolver(
compile_graphql(config_module, operation_type, field.type_of.name(), graphql)
.trace(config::GraphQL::trace_name().as_str())
}
Resolver::Call(call) => compile_call(config_module, call, operation_type, object_name)
Resolver::Call(call) => compile_call(config_module, call, operation_type, container_type)
.trace(config::Call::trace_name().as_str()),
Resolver::Js(js) => {
compile_js(super::CompileJs { js, script: &config_module.extensions().script })
Expand Down

0 comments on commit 0c55ae2

Please sign in to comment.