Skip to content
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

outEdges and inEdges not working #802

Closed
robross0606 opened this issue Feb 13, 2024 · 2 comments
Closed

outEdges and inEdges not working #802

robross0606 opened this issue Feb 13, 2024 · 2 comments

Comments

@robross0606
Copy link

robross0606 commented Feb 13, 2024

edgeCollection.outEdges() and edgeCollection.inEdges() no longer appear to be functional after upgrading from 7.8.0 to 8.6.0. Making a call such as await edgeCollection.outEdges('notLinks/test1') results in this error stack:

    TypeError: Cannot read properties of undefined (reading 'allowDirtyRead')
      at Collection._edges (node_modules/src/collection.ts:3914:13)
      at Collection.outEdges (node_modules/src/collection.ts:3934:17)
      at Object.outEdges (src/__tests__/arango-service.test.js:506:39)

I've reviewed the migration guide and looked at the latest API documentation, but don't see anything listed that should impact this.

@robross0606
Copy link
Author

robross0606 commented Feb 13, 2024

The problem is definitely on collection.ts.

    _edges(selector, options, direction) {
        const { allowDirtyRead = undefined } = options;
        return this._db.request({
            path: `/_api/edges/${encodeURIComponent(this._name)}`,
            allowDirtyRead,
            qs: {
                direction,
                vertex: (0, documents_1._documentHandle)(selector, this._name, false),
            },
        });
    }
    edges(vertex, options) {
        return this._edges(vertex, options);
    }
    inEdges(vertex, options) {
        return this._edges(vertex, options, "in");
    }
    outEdges(vertex, options) {
        return this._edges(vertex, options, "out");
    }

None of these functions has a default for options so it breaks _edges because options is undefined. You cannot destructure something from undefined even if you have a default. This would break if options == undefined:

 const { allowDirtyRead = undefined } = options;

So this works:

await edgeCollection.outEdges('notLinks/test1', {})

But this doesn't:

await edgeCollection.outEdges('notLinks/test1')

@pluma4345
Copy link
Member

Good catch. The argument should be optional given that none of the options are required.

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

No branches or pull requests

2 participants