Created
January 4, 2018 13:18
-
-
Save kbrandwijk/6e693f1cad585cb74fd8e022c7277394 to your computer and use it in GitHub Desktop.
forwardTo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Context, forwardTo } from '../utils' | |
export const Query = { | |
viewer: () => ({}), | |
topExperiences: async (parent, args, ctx: Context, info) => { | |
return ctx.db.query.experiences({ orderBy: 'popularity_DESC' }, info) | |
}, | |
// Here's the magic line | |
paymentAccounts: forwardTo('db'), | |
topHomes: async (parent, args, ctx: Context, info) => { | |
return ctx.db.query.places({ orderBy: 'popularity_DESC' }, info) | |
}, | |
topReservations: async (parent, args, ctx: Context, info) => { | |
return ctx.db.query.restaurants({ orderBy: 'popularity_DESC' }, info) | |
}, | |
featuredDestinations: async (parent, args, ctx: Context, info) => { | |
return ctx.db.query.neighbourhoods( | |
{ orderBy: 'popularity_DESC', where: { featured: true } }, | |
info, | |
) | |
}, | |
experiencesByCity: async (parent, { cities }, ctx: Context, info) => { | |
return ctx.db.query.cities({ | |
where: { | |
name_in: cities, | |
neighbourhoods_every: { | |
locations_every: { | |
experience: { | |
id_gt: '0', | |
}, | |
}, | |
}, | |
}, | |
}) | |
}, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import CitySubscriptionPayload, PaymentAccountWhereInput, PaymentAccountOrderByInput, PLACE_SIZES, DateTime, PAYMENT_PROVIDER, NOTIFICATION_TYPE, CURRENCY from "./generated/database.graphql" | |
type Query { | |
"""This returns hello""" | |
hello: String | |
topExperiences: [Experience!]! | |
topHomes: [Home!]! | |
topReservations: [Reservation!]! | |
featuredDestinations: [Neighbourhood!]! | |
experiencesByCity(cities: [String!]!): [ExperiencesByCity!]! | |
viewer: Viewer | |
# Just copied this line from the database schema, and added the missing imports (WhereInput and OrderByInput) | |
paymentAccounts(where: PaymentAccountWhereInput, orderBy: PaymentAccountOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [PaymentAccount]! | |
} | |
# omitted the rest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment