Last active
October 14, 2017 01:47
-
-
Save govorov/e51db1858a0ac9ff95e584763666b3b5 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
| // | |
| // graphql/resolvers.ts | |
| // | |
| import { cardResolver } from 'graphql/resolvers/card'; | |
| import { cardsResolver } from 'graphql/resolvers/cards'; | |
| export const resolvers = { | |
| Query: { | |
| ...cardsResolver, | |
| ...cardResolver, | |
| }, | |
| }; | |
| // | |
| // graphql/resolvers/card.ts | |
| // | |
| import { getRepository } from 'typeorm'; | |
| import { Card } from 'entities/card'; | |
| export const cardResolver = { | |
| async card(obj, { id }, context, info) { | |
| const repository = getRepository(Card); | |
| return await repository.findOne({ id }); | |
| } | |
| }; | |
| // | |
| // graphql/resolvets/cards.ts | |
| // | |
| import { getRepository } from 'typeorm'; | |
| import { Card } from 'entities/card'; | |
| export const cardsResolver = { | |
| async cards() { | |
| const repository = getRepository(Card); | |
| return await repository.find(); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment