diff --git a/query-engine/core/src/compiler/translate/query/read.rs b/query-engine/core/src/compiler/translate/query/read.rs index 076d4379566..dbe8f16730a 100644 --- a/query-engine/core/src/compiler/translate/query/read.rs +++ b/query-engine/core/src/compiler/translate/query/read.rs @@ -32,6 +32,7 @@ pub(crate) fn translate_read_query(query: ReadQuery, ctx: &Context<'_>) -> Trans ReadQuery::ManyRecordsQuery(mrq) => { let selected_fields = mrq.selected_fields.without_relations().into_virtuals_last(); let needs_reversed_order = mrq.args.needs_reversed_order(); + dbg!(mrq.nested); // TODO: we ignore chunking for now let query = query_builder::read::get_records( diff --git a/query-engine/query-engine/examples/compiler.rs b/query-engine/query-engine/examples/compiler.rs index b725d4bc536..7a1150cc365 100644 --- a/query-engine/query-engine/examples/compiler.rs +++ b/query-engine/query-engine/examples/compiler.rs @@ -1,8 +1,8 @@ use std::sync::Arc; -use indexmap::IndexMap; -use query_core::{query_graph_builder::QueryGraphBuilder, schema::QueryTag, QueryDocument}; -use request_handlers::{Action, FieldQuery, JsonBody, JsonSingleQuery, RequestBody, SelectionSet, SelectionSetValue}; +use query_core::{query_graph_builder::QueryGraphBuilder, QueryDocument}; +use request_handlers::{JsonBody, JsonSingleQuery, RequestBody}; +use serde_json::json; pub fn main() -> anyhow::Result<()> { let schema_string = include_str!("./schema.prisma"); @@ -20,31 +20,31 @@ pub fn main() -> anyhow::Result<()> { // email: Prisma.Param("userEmail") // } // }) - let request = RequestBody::Json(JsonBody::Single(JsonSingleQuery { - model_name: Some("User".into()), - action: Action::new(QueryTag::FindMany), - query: FieldQuery { - arguments: Some({ - let mut map = IndexMap::new(); - map.insert( - "where".into(), - serde_json::json!({ - "email": { - "$type": "Param", - "value": "userEmail", - } - }), - ); - map - }), - selection: SelectionSet::new({ - let mut map = IndexMap::new(); - map.insert("$scalars".into(), SelectionSetValue::Shorthand(true)); - map - }), - }, - })); - + let query: JsonSingleQuery = serde_json::from_value(json!({ + "modelName": "User", + "action": "findMany", + "query": { + "arguments": { + "where": { + "email": { + "$type": "Param", + "value": "userEmail" + } + } + }, + "selection": { + "$scalars": true, + "posts": { + "arguments": {}, + "selection": { + "$scalars": true + } + } + } + } + }))?; + + let request = RequestBody::Json(JsonBody::Single(query)); let doc = request.into_doc(&query_schema)?; let QueryDocument::Single(query) = doc else {