Skip to content
Merged
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
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ This file is the authoritative user-facing release chronology. The former
[release-notes ledger](docs/archive/2026/graphql-orm-release-notes.md) is retained
for historical context.

## 0.35.2 - 2026-10-01

Companion macros crate: `graphql-orm-macros` **0.35.2** (alignment only).

- Allow transaction-bound repository `count` and `exists` with an installed
row policy when its current visibility is explicitly unrestricted or complete
SQL authorization. Intersect complete predicates with caller filters before
the database count, on the same pinned transaction as surrounding writes.
- Retain entity authorization and reject callback-only/prefilter policies,
wrong-entity predicates and residual filters under an installed row policy.
Counts do not decode rows or invoke per-row callbacks. Existing no-policy
behavior, public APIs, GraphQL SDL and stored data are unchanged.

## 0.35.1 - 2026-10-01

Companion macros crate: `graphql-orm-macros` **0.35.1**.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ cynic-parser = { version = "=0.11.2", features = ["pretty"] }
futures = "0.3"
getrandom = "0.3"
graphql-composition = "=0.12.2"
graphql-orm = { path = "crates/graphql-orm", version = "0.35.1", default-features = false }
graphql-orm = { path = "crates/graphql-orm", version = "0.35.2", default-features = false }
graphql-orm-ai-tool-profiles = { path = "crates/graphql-orm-ai-tool-profiles", version = "0.15.0" }
graphql-orm-backup = { path = "crates/graphql-orm-backup", version = "0.7.2", default-features = false }
graphql-orm-operation-catalog = { path = "crates/graphql-orm-operation-catalog", version = "0.4.0" }
Expand Down
14 changes: 14 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ supersedes: []
`graphql-orm` is distributed from GitHub only. Use a reviewed full 40-character commit in `rev`;
neither the runtime nor macros crate is published to crates.io.

## Policy-aware transaction counts (0.35.2)

Adopt aligned runtime/macros 0.35.2. No schema, stored-data, public API or
GraphQL SDL migration is required. Transaction-bound repository `count` and
`exists` now accept current explicit `Unrestricted` visibility or a complete
SQL predicate from the installed row policy. Complete predicates are combined
with caller filters before counting on the existing pinned transaction.

Entity authorization remains required. Callback-only/prefilter visibility and
residual query filters under an installed policy remain rejected; no full-row
scan replaces SQL authorization. Re-evaluate verified identity and ownership
for every call and never declare a partial predicate complete. Existing
no-policy behavior is retained. See [repository helpers](docs/reference/graphql-orm/runtime-and-writes.md#repository-helpers).

## Policy-aware typed projections (0.35.1)

Adopt aligned ORM/macros 0.35.1. No schema or GraphQL SDL migration is required.
Expand Down
2 changes: 1 addition & 1 deletion crates/graphql-orm-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "graphql-orm-macros"
version = "0.35.1"
version = "0.35.2"
edition = "2024"
authors = ["Toby Martin"]
description = "Procedural macros for async-graphql and ORM-backed entities, relations, and CRUD operations."
Expand Down
4 changes: 2 additions & 2 deletions crates/graphql-orm-macros/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ macro/runtime versions aligned:

```toml
[dependencies]
graphql-orm = { git = "https://github.com/Dastari/graphql-orm.git", rev = "<reviewed-full-40-character-commit-sha>", version = "0.35.1", default-features = false, features = ["sqlite"] }
graphql-orm = { git = "https://github.com/Dastari/graphql-orm.git", rev = "<reviewed-full-40-character-commit-sha>", version = "0.35.2", default-features = false, features = ["sqlite"] }
```

Direct use is supported for tooling that needs the macro package:

```toml
graphql-orm-macros = { git = "https://github.com/Dastari/graphql-orm.git", rev = "<reviewed-full-40-character-commit-sha>", version = "0.35.1", default-features = false, features = ["sqlite"] }
graphql-orm-macros = { git = "https://github.com/Dastari/graphql-orm.git", rev = "<reviewed-full-40-character-commit-sha>", version = "0.35.2", default-features = false, features = ["sqlite"] }
```

The direct dependency still requires a compatible `graphql-orm` runtime in the
Expand Down
4 changes: 2 additions & 2 deletions crates/graphql-orm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "graphql-orm"
version = "0.35.1"
version = "0.35.2"
edition = "2024"
description = "Runtime support crate for graphql-orm-macros"
license = "MIT"
Expand Down Expand Up @@ -68,7 +68,7 @@ futures = "0.3"
geo = { version = "0.33", optional = true, default-features = false }
geo-types = { version = "0.7", optional = true }
geojson = { version = "1", optional = true, default-features = true }
graphql-orm-macros = { path = "../graphql-orm-macros", version = "0.35.1", default-features = false }
graphql-orm-macros = { path = "../graphql-orm-macros", version = "0.35.2", default-features = false }
graphql-orm-operation-catalog = { workspace = true }
rust_decimal = { workspace = true }
serde = { version = "1", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/graphql-orm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ backend:

```toml
[dependencies]
graphql-orm = { git = "https://github.com/Dastari/graphql-orm.git", rev = "<reviewed-full-40-character-commit-sha>", version = "0.35.1", default-features = false, features = ["sqlite"] }
graphql-orm = { git = "https://github.com/Dastari/graphql-orm.git", rev = "<reviewed-full-40-character-commit-sha>", version = "0.35.2", default-features = false, features = ["sqlite"] }
```

This unpublished package has no docs.rs release. Use this Git README and the
Expand Down
13 changes: 11 additions & 2 deletions crates/graphql-orm/src/graphql/orm/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -983,13 +983,22 @@ where
)
.await
.map_err(|error| sqlx::Error::Protocol(format!("{error:?}")))?;
if self.hook_ctx.database().row_policy().is_some() {
let database = self.hook_ctx.database();
let visibility = database
.read_visibility::<T>(None, EntityAccessSurface::Repository)
.await
.map_err(crate::graphql::errors::sqlx_error_from_graphql)?;
if visibility.requires_residual_checks()
|| (database.row_policy().is_some() && self.query.requires_in_memory_filtering())
{
return Err(sqlx::Error::Protocol(
"repository count reads require database-visible row-policy predicates".to_string(),
));
}
let query = self.query;
query.count_in_transaction(self.hook_ctx).await
query
.count_with_visibility_in_transaction(self.hook_ctx, visibility.predicate_expression())
.await
}

pub async fn exists(self) -> crate::Result<bool> {
Expand Down
24 changes: 24 additions & 0 deletions crates/graphql-orm/src/graphql/orm/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4075,15 +4075,39 @@ where
&self,
context: &mut MutationContext<'_, B>,
) -> crate::Result<i64>
where
B: WriteBackend,
{
self.count_with_visibility_in_transaction(context, None)
.await
}

#[cfg(any(feature = "sqlite", feature = "postgres", feature = "mssql"))]
pub(crate) async fn count_with_visibility_in_transaction(
&self,
context: &mut MutationContext<'_, B>,
visibility: Option<&FilterExpression>,
) -> crate::Result<i64>
where
B: WriteBackend,
{
if self.requires_in_memory_filtering() {
if visibility.is_some() {
return Err(sqlx::Error::Protocol(
"SQL-authorized counts require database-visible query filters".to_string(),
));
}
let mut query = self.clone();
query.page = None;
return Ok(query.fetch_all_in_transaction(context).await?.len() as i64);
}
let mut query = self.build_select_query()?;
if let Some(predicate) = visibility {
query.filter = Some(match query.filter {
Some(filter) => FilterExpression::And(vec![filter, predicate.clone()]),
None => predicate.clone(),
});
}
query.count_only = true;
query.pagination = None;
query.sorts.clear();
Expand Down
Loading