blob: afb61c339f313d0e14d4cfa5246deab826e50d93 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  | 
import {unique} from '#sugar';
export default {
  query(contribs) {
    const associatedContributionsByOtherArtists =
      contribs
        .flatMap(ownContrib =>
          ownContrib.associatedContributions
            .filter(associatedContrib =>
              associatedContrib.artist !== ownContrib.artist));
    const otherArtists =
      unique(
        associatedContributionsByOtherArtists
          .map(contrib => contrib.artist));
    return {otherArtists};
  },
  relations: (relation, query) => ({
    artistLinks:
      query.otherArtists
        .map(artist => relation('linkArtist', artist)),
  }),
  generate: (relations) =>
    relations.artistLinks,
};
  |