Skip to content

Commit

Permalink
feat: add limit argument to relatedResources
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Aug 13, 2020
1 parent 489d004 commit cc22434
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions plugins/gatsby-source-swiftype/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,19 @@ exports.createResolvers = ({ createResolvers }) => {
createResolvers({
Mdx: {
relatedResources: {
args: {
limit: {
type: 'Int',
defaultValue: 5,
},
},
type: ['RelatedResource!'],
resolve(source, _args, context) {
return context.nodeModel.getNodesByIds({ ids: source.children });
resolve(source, args, context) {
const { limit } = args;

return context.nodeModel
.getNodesByIds({ ids: source.children })
.slice(0, Math.max(limit, 0));
},
},
},
Expand Down

0 comments on commit cc22434

Please sign in to comment.