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

Function insert

tests/graph/integration/postgres/links.rs:31–261  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29#[tokio::test]
30#[expect(clippy::too_many_lines)]
31async fn insert() {
32 let alice = serde_json::from_str(entity::PERSON_ALICE_V1).expect("could not parse entity");
33 let bob = serde_json::from_str(entity::PERSON_BOB_V1).expect("could not parse entity");
34 let friend_of = PropertyObject::empty();
35
36 let mut database = DatabaseTestWrapper::new().await;
37 let mut api = database
38 .seed(
39 [
40 data_type::VALUE_V1,
41 data_type::TEXT_V1,
42 data_type::NUMBER_V1,
43 ],
44 [
45 property_type::NAME_V1,
46 property_type::AGE_V1,
47 property_type::FAVORITE_SONG_V1,
48 property_type::FAVORITE_FILM_V1,
49 property_type::HOBBY_V1,
50 property_type::INTERESTS_V1,
51 ],
52 [
53 entity_type::LINK_V1,
54 entity_type::link::FRIEND_OF_V1,
55 entity_type::link::ACQUAINTANCE_OF_V1,
56 entity_type::PERSON_V1,
57 ],
58 )
59 .await
60 .expect("could not seed database");
61
62 let person_type_id = VersionedUrl {
63 base_url: BaseUrl::new(
64 "https://blockprotocol.org/@alice/types/entity-type/person/".to_owned(),
65 )
66 .expect("couldn't construct Base URL"),
67 version: OntologyTypeVersion {
68 major: 1,
69 pre_release: None,
70 },
71 };
72
73 let alice_entity = api
74 .create_entity(
75 api.account_id,
76 CreateEntityParams {
77 web_id: WebId::new(api.account_id),
78 entity_uuid: None,
79 decision_time: None,
80 entity_type_ids: HashSet::from([person_type_id.clone()]),
81 properties: PropertyObjectWithMetadata::from_parts(alice, None)
82 .expect("could not create property with metadata object"),
83 link_data: None,
84 draft: false,
85 policies: Vec::new(),
86 confidence: None,
87 provenance: ProvidedEntityEditionProvenance {
88 actor_type: ActorType::User,

Callers

nothing calls this directly

Calls 14

allFunction · 0.85
create_entityMethod · 0.80
unwrapMethod · 0.80
emptyFunction · 0.50
fromFunction · 0.50
defaultFunction · 0.50
expectMethod · 0.45
seedMethod · 0.45
to_ownedMethod · 0.45
cloneMethod · 0.45
query_entitiesMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected