feat: add named graph wrapping functionality - #62
Conversation
…tion or class' Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a namedGraph utility that exposes a DatasetCore view of a single named graph as default-graph quads, enabling existing TermWrapper/DatasetWrapper usage scoped to a graph.
Changes:
- Introduces
namedGraph()and aNamedGraphDatasetimplementation that projects one named graph into the default graph and maps writes back. - Adds
NamedGraphErrorand exports it along withnamedGraphfrom the package entrypoint. - Adds unit + integration tests and documents the feature in the README.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/namedGraph.ts |
Implements the named-graph-to-default-graph dataset view and write-through behavior. |
src/errors/NamedGraphError.ts |
Defines the error thrown when callers try to use non-default graphs on the view. |
src/mod.ts |
Exports namedGraph and NamedGraphError from the public module. |
test/unit/named_graph.test.ts |
Unit tests for projection, size, has, add/delete, and error cases. |
test/unit/named_graph_integration.test.ts |
Integration tests verifying compatibility with TermWrapper/DatasetWrapper patterns. |
README.md |
Adds documentation and examples for the new named graph view feature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot rather than implementing #62 (comment) -- support only |
Agent-Logs-Url: https://github.com/rdfjs/wrapper/sessions/05cfefef-18c2-4e8e-a838-9ef95107a56d Co-authored-by: jeswr <63333554+jeswr@users.noreply.github.com>
Changed |
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
1 similar comment
|
@copilot please do implement caching as suggested in #62 (comment) - make sure this cache is cleared when an update operation takes place. |
Agent-Logs-Url: https://github.com/rdfjs/wrapper/sessions/35227618-a325-483d-b93c-07227a860a49 Co-authored-by: jeswr <63333554+jeswr@users.noreply.github.com>
Implemented caching via a |
|
@langsamu this PR is ready for review |
There was a problem hiding this comment.
Lovely addition.
I have reworked it in #63 (leaving the fundamental feature intact):
- No caching. There is no caching anywhere else, so let's not start now. It's unrelated to the new feature, irrelevant, untested and premature.
- Your function
namedGraphis now a member of the existingDatasetWrapper, where we already have an underlyingDatasetCoreand aDataFactory. But most importantly, aDatasetWrapperis where I imagine most people will start their mapping and traversal journey, so I'd like all navigation to start there. - I've made your class
NamedGraphDatasetpublic and a subclass ofDatasetWrapper, because that is what it is. Might as well enjoy the benefits. No functional changes there. - The new utility method
DatasetWrapper#namedreturns a subclass of the above. This is how we maintain the context (underlying dataset and factory) as we traverse graph patterns down the property chain. We still want to wrap on top of (inside of) the named graph projection. - Made some minor changes to the guards and errors so they're aligned with the rest of the codebase.
|
Could we make a version that writes to a specific graph but reads from all graphs? I'm happy to help given we agree on an interface. |
langsamu
left a comment
There was a problem hiding this comment.
I suggest we merge and leave documentation improvements for later.
@langsamu this PR is ready for review
Partially resolves #43
This PR introduces
namedGraphfunction which creates aDatasetCoreview over a single named graph, projecting its contents into the default graph. This lets you use any existingTermWrapperorDatasetWrapperclasses unchanged, scoped to a specific graph.Writes through the view are mapped back to the named graph in the underlying dataset:
Any attempt to use a non-default graph on the returned
DatasetCorethrows aNamedGraphError: