Support fetching ISRCs for nested recording entites (#75)

This commit is contained in:
Brian Beck 2018-08-15 20:20:39 -07:00 committed by GitHub
parent ba21977847
commit 01ebffad01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,