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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw error when launch not found #352

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions final/server/src/resolvers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { paginateResults } = require('./utils');
const { PubSub } = require('graphql-subscriptions');
const { GraphQLUpload } = require('graphql-upload');
const { GraphQLError } = require('graphql');

const TRIPS_BOOKED = 'TRIPS_BOOKED';
const pubsub = new PubSub();
Expand Down Expand Up @@ -35,8 +36,17 @@ module.exports = {
: false,
};
},
launch: (_, { id }, { dataSources }) =>
dataSources.launchAPI.getLaunchById({ launchId: id }),
launch: async (_, { id }, { dataSources }) => {
const launchResult = await dataSources.launchAPI.getLaunchById({ launchId: id });
if (!launchResult) {
throw new GraphQLError('Launch not found', {
extensions: {
code: 'NOT_FOUND',
},
});
}
return launchResult;
},
me: async (_, __, { dataSources }) =>
dataSources.userAPI.findOrCreateUser(),
totalTripsBooked: (_, __, { dataSources }) => dataSources.userAPI.countTrips()
Expand Down