Skip to content

Commit

Permalink
Stop depending on subgraph when sorting by ontology IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
TimDiekmann committed Sep 18, 2024
1 parent 4c3da0e commit bd36060
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 265 deletions.
24 changes: 12 additions & 12 deletions apps/hash-graph/libs/api/openapi/openapi.json

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

6 changes: 2 additions & 4 deletions apps/hash-graph/libs/api/src/rest/data_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ use graph_types::{
},
owned_by_id::OwnedById,
};
use hash_graph_store::{
data_type::DataTypeQueryToken, subgraph::identifier::DataTypeVertexId, ConflictBehavior,
};
use hash_graph_store::{data_type::DataTypeQueryToken, ConflictBehavior};
use hash_status::Status;
use serde::{Deserialize, Serialize};
use temporal_client::TemporalClient;
Expand Down Expand Up @@ -455,7 +453,7 @@ where
#[serde(rename_all = "camelCase")]
struct GetDataTypeSubgraphResponse {
subgraph: Subgraph,
cursor: Option<DataTypeVertexId>,
cursor: Option<VersionedUrl>,
}

#[utoipa::path(
Expand Down
6 changes: 2 additions & 4 deletions apps/hash-graph/libs/api/src/rest/entity_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ use graph_types::{
},
owned_by_id::OwnedById,
};
use hash_graph_store::{
entity_type::EntityTypeQueryToken, subgraph::identifier::EntityTypeVertexId, ConflictBehavior,
};
use hash_graph_store::{entity_type::EntityTypeQueryToken, ConflictBehavior};
use hash_map::HashMap;
use serde::{Deserialize, Serialize};
use temporal_client::TemporalClient;
Expand Down Expand Up @@ -747,7 +745,7 @@ where
#[serde(rename_all = "camelCase")]
struct GetEntityTypeSubgraphResponse {
subgraph: Subgraph,
cursor: Option<EntityTypeVertexId>,
cursor: Option<VersionedUrl>,
count: Option<usize>,
#[serde(skip_serializing_if = "Option::is_none")]
#[schema(nullable = false)]
Expand Down
7 changes: 2 additions & 5 deletions apps/hash-graph/libs/api/src/rest/property_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ use graph_types::{
},
owned_by_id::OwnedById,
};
use hash_graph_store::{
property_type::PropertyTypeQueryToken, subgraph::identifier::PropertyTypeVertexId,
ConflictBehavior,
};
use hash_graph_store::{property_type::PropertyTypeQueryToken, ConflictBehavior};
use hash_status::Status;
use serde::{Deserialize, Serialize};
use temporal_client::TemporalClient;
Expand Down Expand Up @@ -444,7 +441,7 @@ where
#[serde(rename_all = "camelCase")]
struct GetPropertyTypeSubgraphResponse {
subgraph: Subgraph,
cursor: Option<PropertyTypeVertexId>,
cursor: Option<VersionedUrl>,
}

#[utoipa::path(
Expand Down
15 changes: 8 additions & 7 deletions apps/hash-graph/libs/graph/src/store/crud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use hash_graph_store::{
subgraph::{temporal_axes::QueryTemporalAxes, SubgraphRecord},
};
use tracing::instrument;
use type_system::url::VersionedUrl;

use crate::store::QueryError;

Expand All @@ -32,12 +33,12 @@ pub trait Sorting {
fn set_cursor(&mut self, cursor: Self::Cursor);
}

pub struct VertexIdSorting<R: SubgraphRecord> {
pub cursor: Option<R::VertexId>,
pub struct VersionedUrlSorting {
pub cursor: Option<VersionedUrl>,
}

impl<R: SubgraphRecord> Sorting for VertexIdSorting<R> {
type Cursor = R::VertexId;
impl Sorting for VersionedUrlSorting {
type Cursor = VersionedUrl;

fn cursor(&self) -> Option<&Self::Cursor> {
self.cursor.as_ref()
Expand Down Expand Up @@ -90,12 +91,12 @@ impl<'f, R: QueryRecord, S> ReadParameter<'f, R, S> {

impl<'f, R: SubgraphRecord + QueryRecord, S> ReadParameter<'f, R, S> {
#[must_use]
pub fn sort_by_vertex_id(self) -> ReadParameter<'f, R, VertexIdSorting<R>> {
pub fn sort_by_vertex_id(self) -> ReadParameter<'f, R, VersionedUrlSorting> {
ReadParameter {
filters: self.filters,
temporal_axes: self.temporal_axes,
include_drafts: self.include_drafts,
sorting: Some(VertexIdSorting { cursor: None }),
sorting: Some(VersionedUrlSorting { cursor: None }),
limit: self.limit,
}
}
Expand Down Expand Up @@ -150,7 +151,7 @@ impl<'f, R: QueryRecord, S: Sorting> ReadParameter<'f, R, S> {
/// Read access to a [`Store`].
///
/// [`Store`]: crate::store::Store
pub trait ReadPaginated<R: QueryRecord, S: Sorting + Sync = VertexIdSorting<R>>: Read<R> {
pub trait ReadPaginated<R: QueryRecord, S: Sorting + Sync>: Read<R> {
type QueryResult: QueryResult<R, S> + Send;

type ReadPaginatedStream: Stream<Item = Result<Self::QueryResult, QueryError>> + Send + Sync;
Expand Down
31 changes: 13 additions & 18 deletions apps/hash-graph/libs/graph/src/store/ontology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ use graph_types::{
};
use hash_graph_store::{
filter::Filter,
subgraph::{
edges::GraphResolveDepths,
identifier::{DataTypeVertexId, EntityTypeVertexId, PropertyTypeVertexId},
temporal_axes::QueryTemporalAxesUnresolved,
Subgraph,
},
subgraph::{edges::GraphResolveDepths, temporal_axes::QueryTemporalAxesUnresolved, Subgraph},
ConflictBehavior,
};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -63,7 +58,7 @@ pub struct GetDataTypeSubgraphParams<'p> {
pub temporal_axes: QueryTemporalAxesUnresolved,
pub include_drafts: bool,
#[serde(default)]
pub after: Option<DataTypeVertexId>,
pub after: Option<VersionedUrl>,
#[serde(default)]
pub limit: Option<usize>,
#[serde(default)]
Expand All @@ -73,7 +68,7 @@ pub struct GetDataTypeSubgraphParams<'p> {
#[derive(Debug)]
pub struct GetDataTypeSubgraphResponse {
pub subgraph: Subgraph,
pub cursor: Option<DataTypeVertexId>,
pub cursor: Option<VersionedUrl>,
pub count: Option<usize>,
}

Expand All @@ -96,7 +91,7 @@ pub struct GetDataTypesParams<'p> {
pub temporal_axes: QueryTemporalAxesUnresolved,
pub include_drafts: bool,
#[serde(default)]
pub after: Option<DataTypeVertexId>,
pub after: Option<VersionedUrl>,
#[serde(default)]
pub limit: Option<usize>,
#[serde(default)]
Expand All @@ -108,7 +103,7 @@ pub struct GetDataTypesParams<'p> {
#[serde(rename_all = "camelCase")]
pub struct GetDataTypesResponse {
pub data_types: Vec<DataTypeWithMetadata>,
pub cursor: Option<DataTypeVertexId>,
pub cursor: Option<VersionedUrl>,
pub count: Option<usize>,
}

Expand Down Expand Up @@ -303,7 +298,7 @@ pub struct GetPropertyTypeSubgraphParams<'p> {
pub temporal_axes: QueryTemporalAxesUnresolved,
pub include_drafts: bool,
#[serde(default)]
pub after: Option<PropertyTypeVertexId>,
pub after: Option<VersionedUrl>,
#[serde(default)]
pub limit: Option<usize>,
#[serde(default)]
Expand All @@ -313,7 +308,7 @@ pub struct GetPropertyTypeSubgraphParams<'p> {
#[derive(Debug)]
pub struct GetPropertyTypeSubgraphResponse {
pub subgraph: Subgraph,
pub cursor: Option<PropertyTypeVertexId>,
pub cursor: Option<VersionedUrl>,
pub count: Option<usize>,
}

Expand All @@ -336,7 +331,7 @@ pub struct GetPropertyTypesParams<'p> {
pub temporal_axes: QueryTemporalAxesUnresolved,
pub include_drafts: bool,
#[serde(default)]
pub after: Option<PropertyTypeVertexId>,
pub after: Option<VersionedUrl>,
#[serde(default)]
pub limit: Option<usize>,
#[serde(default)]
Expand All @@ -348,7 +343,7 @@ pub struct GetPropertyTypesParams<'p> {
#[serde(rename_all = "camelCase")]
pub struct GetPropertyTypesResponse {
pub property_types: Vec<PropertyTypeWithMetadata>,
pub cursor: Option<PropertyTypeVertexId>,
pub cursor: Option<VersionedUrl>,
pub count: Option<usize>,
}

Expand Down Expand Up @@ -543,7 +538,7 @@ pub struct GetEntityTypeSubgraphParams<'p> {
pub filter: Filter<'p, EntityTypeWithMetadata>,
pub graph_resolve_depths: GraphResolveDepths,
pub temporal_axes: QueryTemporalAxesUnresolved,
pub after: Option<EntityTypeVertexId>,
pub after: Option<VersionedUrl>,
pub limit: Option<usize>,
pub include_drafts: bool,
#[serde(default)]
Expand All @@ -557,7 +552,7 @@ pub struct GetEntityTypeSubgraphParams<'p> {
#[derive(Debug)]
pub struct GetEntityTypeSubgraphResponse {
pub subgraph: Subgraph,
pub cursor: Option<EntityTypeVertexId>,
pub cursor: Option<VersionedUrl>,
pub count: Option<usize>,
pub web_ids: Option<HashMap<OwnedById, usize>>,
pub edition_created_by_ids: Option<HashMap<EditionCreatedById, usize>>,
Expand All @@ -583,7 +578,7 @@ pub struct GetEntityTypesParams<'p> {
pub temporal_axes: QueryTemporalAxesUnresolved,
pub include_drafts: bool,
#[serde(default)]
pub after: Option<EntityTypeVertexId>,
pub after: Option<VersionedUrl>,
#[serde(default)]
pub limit: Option<usize>,
#[serde(default)]
Expand All @@ -599,7 +594,7 @@ pub struct GetEntityTypesParams<'p> {
#[serde(rename_all = "camelCase")]
pub struct GetEntityTypesResponse {
pub entity_types: Vec<EntityTypeWithMetadata>,
pub cursor: Option<EntityTypeVertexId>,
pub cursor: Option<VersionedUrl>,
pub count: Option<usize>,
#[serde(skip_serializing_if = "Option::is_none")]
#[cfg_attr(feature = "utoipa", schema(nullable = false))]
Expand Down
Loading

0 comments on commit bd36060

Please sign in to comment.