Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Add airports gql
Browse files Browse the repository at this point in the history
  • Loading branch information
anduong96 committed Feb 7, 2024
1 parent 87077f7 commit 439dfeb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,13 @@ type Query {
airportTsaWaitTime(airportIata: String!): [AirportTsaWaitTime!]
airportWeather(airportIata: String!, date: Int!, hour: Int!, month: Int!, year: Int!): AirportWeather!
airportWeatherDay(airportIata: String!, date: Int!, month: Int!, year: Int!): [AirportWeather!]!

"""List of airports"""
airports: [Airport!]!
flight(flightID: String!): Flight!
flightPromptness(flightID: String!): FlightPromptness!
flights(airlineIata: String!, date: Int!, flightNumber: String!, month: Int!, year: Int!): [Flight!]!
flightsWithAirports(airlineIata: String!, date: Int!, destinationIata: String!, month: Int!, originIata: String!, year: Int!): [Flight!]!
health: String!
recentFeedback: Feedback
user: User!
Expand Down
1 change: 1 addition & 0 deletions src/api/graphql/_decorators/selection.decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function parseGraphQLInfo<T extends object = object>(
export function Selections(root?: string) {
return createParamDecorator<ApolloServerContext>(({ info }) => {
const selection = omit(parseGraphQLInfo(info), ['__typename']);

if (root) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return get(selection, root);
Expand Down
10 changes: 10 additions & 0 deletions src/api/graphql/resolvers/airport.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,14 @@ export class AirportResolver {
const entry = await getTsaWaitTimeForFlight(iata);
return entry;
}

@Authorized()
@Query(() => [GQL_Airport], {
description: 'List of airports',
})
airports(@Selections() selections: object) {
return prisma.airport.findMany({
select: selections,
});
}
}

0 comments on commit 439dfeb

Please sign in to comment.