Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants