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

Bug in cancelTrip method from User datasource #116

Open
aruprakshit opened this issue Jan 10, 2020 · 0 comments
Open

Bug in cancelTrip method from User datasource #116

aruprakshit opened this issue Jan 10, 2020 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@aruprakshit
Copy link

aruprakshit commented Jan 10, 2020

return !!this.store.trips.destroy({ where: { userId, launchId } });

Due to this line cancelTrip throws an error.

{
  "errors": [
    {
      "message": "Cannot read property 'flight_number' of undefined",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "cancelTrip"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "TypeError: Cannot read property 'flight_number' of undefined",
      // ....

Following change will fix the error.

async cancelTrip({ launchId }) {
    const userId = this.context.user.id;
    const numberOfDeletedTrips = await this.store.trips.destroy({ where: { userId, launchId } });
    return numberOfDeletedTrips !== 0;
  }

As per the doc of destroy it returns number of deleted resources wrapped in Promise. So it should be resolved to get the count to decide if resources are deleted or not.

aruprakshit added a commit to aruprakshit/fullstack-tutorial that referenced this issue Jan 10, 2020
The issue is explained in the apollographql#116.
@stemmlerjs stemmlerjs self-assigned this Feb 18, 2020
@stemmlerjs stemmlerjs added the bug Something isn't working label Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants