Skip to content

Commit

Permalink
Demo with createResolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
LoicMahieu committed Mar 7, 2019
1 parent 8aaf0d0 commit c479b56
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 0 additions & 4 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ module.exports = {
options: {
only: node => node.sourceInstanceName === 'Comment',
typeName: () => 'CommentsJson',
transform: obj => ({
...obj,
post___NODE: obj.postId
}),
createNodeId: (node, originalNode) => originalNode.name
}
},
Expand Down
13 changes: 13 additions & 0 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@
*
* See: https://www.gatsbyjs.org/docs/node-apis/
*/

exports.createResolvers = ({ createResolvers }) => {
createResolvers({
CommentsJson: {
post: {
type: `PostsJson`,
resolve (source, args, context, info) {
return context.nodeModel.getNodeById({ id: source.postId })
}
}
}
})
}

0 comments on commit c479b56

Please sign in to comment.