Skip to content

feat: add SingularNullable getter arity and singular error handling#18

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-more-arity-support
Draft

feat: add SingularNullable getter arity and singular error handling#18
Copilot wants to merge 2 commits intomainfrom
copilot/add-more-arity-support

Conversation

Copy link

Copilot AI commented Feb 12, 2026

Adds more arities for selecting terms beyond Singular, and adds proper error handling to singular() per the approach in #13.

Changes

  • GetterArity.SingularNullable — new enum variant enabling nullable term selection via decorators, complementing the existing singularNullable() method on TermWrapper
  • getter decorator — routes SingularNullable to this.singularNullable()
  • singular() error handling — throws descriptive error when no matching quad exists instead of crashing on undefined. Uses iterator to avoid materializing all matching quads (relevant for lazy datasets like N3.js)

Usage

// Decorator-based nullable getter (new)
@getter(Vocabulary.hasName, GetterArity.SingularNullable, ValueMappings.literalToString)
public get hasName(): string | undefined {
    throw new Error
}

// singular() now throws with a clear message when value is missing
// "No value found for predicate https://example.org/hasChild on term y"
Original prompt

This section details on the original issue you should resolve

<issue_title>Improvement: More arities</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)

@jeswr As I understand, this PR should implement more arities for selecting terms; in addition to `signular`. This should contain the same kind of error handling logic that exists in https://github.com//pull/13

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- Add SingularNullable variant to GetterArity enum
- Update getter decorator to handle SingularNullable case
- Add error handling to singular() method that throws when no value found
- Use iterator approach to avoid materializing all matching quads
- Add tests for all new functionality

Co-authored-by: jeswr <63333554+jeswr@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement more arities for selecting terms feat: add SingularNullable getter arity and singular error handling Feb 12, 2026
Copilot AI requested a review from jeswr February 12, 2026 15:07
Copy link
Collaborator

@langsamu langsamu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parts related to new branch on decorator are fine.
Others are unrelated and should be removed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes here are unrelated and should be removed.
NB covered by #13.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@langsamu
Copy link
Collaborator

This change does not fix #8, which is a stub issue for the much broader, generic concern of adding many more 'arities' (a misnomer while we come up with better terminology).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improvement: More arities

3 participants