From bdfd19d87e853fbcd2e590ec4346e5057c638cff Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Fri, 30 Aug 2024 00:27:37 +0300 Subject: Always output the top-level graph when compacting. This makes sure that the API is always consistent. Signed-off-by: Munyoki Kilyungi --- gn3/db/rdf/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gn3/db') diff --git a/gn3/db/rdf/__init__.py b/gn3/db/rdf/__init__.py index c763810..ffb75e5 100644 --- a/gn3/db/rdf/__init__.py +++ b/gn3/db/rdf/__init__.py @@ -173,13 +173,16 @@ def sparql_construct_query(query: str, endpoint: str) -> dict: def query_frame_and_compact(query: str, context: dict, endpoint: str) -> dict: """Frame and then compact the results given a context""" results = sparql_construct_query(query, endpoint) - return jsonld.compact(jsonld.frame(results, context), context) + return jsonld.compact( + jsonld.frame(results, context), + context, + options={"graph": True}) def query_and_compact(query: str, context: dict, endpoint: str) -> dict: """Compact the results given a context""" results = sparql_construct_query(query, endpoint) - return jsonld.compact(results, context) + return jsonld.compact(results, context, options={"graph": True}) def query_and_frame(query: str, context: dict, endpoint: str) -> dict: -- cgit v1.2.3