aboutsummaryrefslogtreecommitdiff
path: root/gn3/db/rdf
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-08-30 00:27:37 +0300
committerBonfaceKilz2024-09-05 16:39:14 +0300
commitbdfd19d87e853fbcd2e590ec4346e5057c638cff (patch)
tree4db234109988be3f283894b7f32c44a11af3d37b /gn3/db/rdf
parent786b8cb5059de5cbeed1d20c4f02728300248452 (diff)
downloadgenenetwork3-bdfd19d87e853fbcd2e590ec4346e5057c638cff.tar.gz
Always output the top-level graph when compacting.
This makes sure that the API is always consistent. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn3/db/rdf')
-rw-r--r--gn3/db/rdf/__init__.py7
1 files changed, 5 insertions, 2 deletions
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: