MCPcopy Create free account
hub / github.com/hashintel/hash / query

Function query

tests/graph/integration/postgres/entity.rs:120–191  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

118
119#[tokio::test]
120async fn query() {
121 let organization: PropertyObject =
122 serde_json::from_str(entity::ORGANIZATION_V1).expect("could not parse entity");
123
124 let mut database = DatabaseTestWrapper::new().await;
125 let mut api = database
126 .seed(
127 [data_type::VALUE_V1, data_type::TEXT_V1],
128 [property_type::NAME_V1],
129 [entity_type::ORGANIZATION_V1],
130 )
131 .await
132 .expect("could not seed database");
133
134 let entity = api
135 .create_entity(
136 api.account_id,
137 CreateEntityParams {
138 web_id: WebId::new(api.account_id),
139 entity_uuid: None,
140 decision_time: None,
141 entity_type_ids: HashSet::from([VersionedUrl {
142 base_url: BaseUrl::new(
143 "https://blockprotocol.org/@alice/types/entity-type/organization/"
144 .to_owned(),
145 )
146 .expect("couldn't construct Base URL"),
147 version: OntologyTypeVersion {
148 major: 1,
149 pre_release: None,
150 },
151 }]),
152 properties: PropertyObjectWithMetadata::from_parts(organization.clone(), None)
153 .expect("could not create property with metadata object"),
154 confidence: None,
155 link_data: None,
156 draft: false,
157 policies: Vec::new(),
158 provenance: ProvidedEntityEditionProvenance {
159 actor_type: ActorType::User,
160 origin: OriginProvenance::from_empty_type(OriginType::Api),
161 sources: Vec::new(),
162 },
163 read_only: false,
164 },
165 )
166 .await
167 .expect("could not create entity");
168
169 let queried_organizations = Box::pin(api.query_entities(
170 api.account_id,
171 QueryEntitiesParams {
172 filter: Filter::for_entity_by_entity_id(entity.metadata.record_id.entity_id),
173 temporal_axes: QueryTemporalAxesUnresolved::all(),
174 sorting: EntityQuerySorting {
175 paths: Vec::new(),
176 cursor: None,
177 },

Callers

nothing calls this directly

Calls 9

allFunction · 0.85
create_entityMethod · 0.80
fromFunction · 0.50
for_entity_by_entity_idFunction · 0.50
expectMethod · 0.45
seedMethod · 0.45
to_ownedMethod · 0.45
cloneMethod · 0.45
query_entitiesMethod · 0.45

Tested by

no test coverage detected