|
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.
fullstack-tutorial/start/server/src/datasources/user.js
Line 60 in 66431a7
Due to this line
cancelTripthrows 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.
As per the doc of
destroyit 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.