Last active
September 7, 2020 07:05
-
-
Save alfari16/e4e98200f7982d23b12f83bd540578d6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // resolvers.ts | |
| import Knex from 'knex'; | |
| import {IGraphQLSchemaContext, Merchant} from '../../types'; | |
| export default { | |
| Query: { | |
| allMerchants() { | |
| return Knex(config.get('database'))('merchants'); | |
| }, | |
| }, | |
| Merchant: { | |
| products({id: merchantId}: Merchant, _: Record<string, any>, {loaders}: IGraphQLSchemaContext) { | |
| return loaders.getProductsByMerchantId.load(merchantId); | |
| }, | |
| location({id: merchantId}: Merchant, _: Record<string, any>, {loaders}: IGraphQLSchemaContext) { | |
| return loaders.getLocationsByMerchantId.load(merchantId); | |
| } | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment