From 01ebffad017e783a796081b757ab1b2d7e3b7fbb Mon Sep 17 00:00:00 2001 From: Brian Beck Date: Wed, 15 Aug 2018 20:20:39 -0700 Subject: [PATCH] Support fetching ISRCs for nested recording entites (#75) --- src/types/recording.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/types/recording.js b/src/types/recording.js index db6e0c3..ce4a23d 100644 --- a/src/types/recording.js +++ b/src/types/recording.js @@ -45,7 +45,18 @@ or mixing.`, isrcs: { type: new GraphQLList(ISRC), description: `A list of [International Standard Recording Codes](https://musicbrainz.org/doc/ISRC) -(ISRCs) for this recording.` +(ISRCs) for this recording.`, + resolve: (source, args, context) => { + if (source.isrcs) { + return source.isrcs + } + // TODO: Add support for parent entities knowing to include this `inc` + // parameter in their own calls by inspecting what fields are requested + // or batching things at the loader level. + return context.loaders.lookup + .load(['recording', source.id, { inc: 'isrcs' }]) + .then(recording => recording.isrcs) + } }, length: { type: Duration,