Skip to content

Add graph extraction helpers to make it easier to use NVL #517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 17, 2025

Conversation

OskarDamkjaer
Copy link
Collaborator

No description provided.

Copy link

changeset-bot bot commented May 28, 2025

⚠️ No Changeset found

Latest commit: 5fbdb59

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@OskarDamkjaer OskarDamkjaer requested a review from ncordon June 5, 2025 13:58
@OskarDamkjaer OskarDamkjaer marked this pull request as ready for review June 10, 2025 08:37
@OskarDamkjaer OskarDamkjaer requested a review from anderson4j June 12, 2025 13:43
Copy link
Collaborator

@anderson4j anderson4j left a comment

Choose a reason for hiding this comment

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

Looks good. I had some small comments, but after you decide on those it should be fine to merge

/**
* Result type containing deduplicated nodes and relationships extracted from Neo4j records.
*/
export type DeduplicatedBasicNodesAndRels = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does the "Basic" part here mean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Orginally we named the nodes BasicNode to avoid clashing with the web browser api Node and to distinguish from the Nodes used in NVL. Here we don't have that problem, so I'll drop the basic part for now

}: { nodeLimit?: number; keepDanglingRels?: boolean } = {},
): DeduplicatedBasicNodesAndRels => {
let limitHit = false;
if (records.length === 0) {
Copy link
Collaborator

@anderson4j anderson4j Jun 16, 2025

Choose a reason for hiding this comment

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

This check looks like it isnt needed. Do you think it makes the code clearer/gives a worthwhile optimization, or what do you think about removing it and instead having a test like:

test('should not break on empty bolt records', () => {
    const { nodes, relationships, limitHit } = extractUniqueNodesAndRels([]);

    if (
      nodes === undefined ||
      relationships === undefined || 
      limitHit === undefined
    ) {
      throw new Error('Invalid return values on empty array of paths');
    }

    expect(nodes.length).toBe(0);
    expect(relationships.length).toBe(0);
    expect(limitHit).toBe(false);
  });

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added a test similar to this now, thanks 👍

@OskarDamkjaer OskarDamkjaer merged commit 5b36986 into main Jun 17, 2025
7 checks passed
@OskarDamkjaer OskarDamkjaer deleted the add-mappers branch June 17, 2025 08:54
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.

2 participants