Last active
July 25, 2018 20:46
-
-
Save tomitrescak/e31b20d2427ca8336c87a991cf6cab4c to your computer and use it in GitHub Desktop.
Medium - Resolvers
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
| // the types below do all the heavy lifting of making everything type safe | |
| import { Mutation, Notification, Query, Resolver } from './utils'; | |
| export const query: Query = { | |
| // hit cmd+space and feel the magic | |
| // params and ctx are type safe, parent and info are 'any' | |
| notifications(_parent, params, ctx, info) { | |
| } | |
| }; | |
| export const mutation: Mutation = { | |
| notify(_parent, args, ctx, info) {} | |
| }; | |
| export const resolver: Resolver<Notification> = { | |
| // we provide two version of the solution, where type names in resolver are NOT type safe, | |
| // or with a bit of extra work we can make it type safe | |
| Notification: { | |
| // parent, ctx is type safe, args and info is any | |
| text: async (parent, _args, ctx, info) => {} | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment