Last active
February 20, 2017 23:10
-
-
Save RyanCCollins/e2fb98e38e479df4eefe7a95912f1d18 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
// From server/graph/queries/post/posts.ts | |
import { | |
GraphQLList, | |
} from 'graphql'; | |
import types from '../../types'; | |
import PostModel from '../../../db/models/post'; | |
export default { | |
type: new GraphQLList(types.postType), | |
args: {}, | |
resolve() { | |
return PostModel | |
.find() | |
.exec(); | |
}, | |
}; |
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
// From server/graph/queries/post/post.ts | |
import { | |
GraphQLNonNull, | |
GraphQLID, | |
} from 'graphql'; | |
import types from '../../types'; | |
import PostModel from '../../../db/models/post'; | |
export default { | |
type: types.postType, | |
args: { | |
id: { | |
type: new GraphQLNonNull(GraphQLID), | |
}, | |
}, | |
resolve(_, args, __) { | |
return PostModel | |
.findById(args.id) | |
.populate('comments') | |
.exec(); | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment