2016-08-20 05:59:32 +00:00
|
|
|
import { GraphQLObjectType, GraphQLString, GraphQLList } from 'graphql/type'
|
|
|
|
|
import Entity from './entity'
|
|
|
|
|
import Alias from './alias'
|
|
|
|
|
import Area from './area'
|
2016-08-08 07:54:06 +00:00
|
|
|
import {
|
2016-08-20 05:59:32 +00:00
|
|
|
getFallback,
|
|
|
|
|
fieldWithID,
|
|
|
|
|
id,
|
|
|
|
|
name,
|
|
|
|
|
sortName,
|
|
|
|
|
disambiguation,
|
|
|
|
|
lifeSpan,
|
|
|
|
|
recordings,
|
|
|
|
|
releases,
|
|
|
|
|
releaseGroups,
|
|
|
|
|
works,
|
|
|
|
|
relations,
|
|
|
|
|
createPageType
|
|
|
|
|
} from './helpers'
|
2016-08-08 07:54:06 +00:00
|
|
|
|
2016-08-20 05:59:32 +00:00
|
|
|
const Artist = new GraphQLObjectType({
|
2016-08-08 07:54:06 +00:00
|
|
|
name: 'Artist',
|
|
|
|
|
description:
|
|
|
|
|
'An artist is generally a musician, a group of musicians, or another ' +
|
|
|
|
|
'music professional (composer, engineer, illustrator, producer, etc.)',
|
2016-08-20 05:59:32 +00:00
|
|
|
interfaces: () => [Entity],
|
2016-08-08 07:54:06 +00:00
|
|
|
fields: () => ({
|
2016-08-20 05:59:32 +00:00
|
|
|
id,
|
|
|
|
|
name,
|
|
|
|
|
sortName,
|
|
|
|
|
disambiguation,
|
|
|
|
|
aliases: {
|
|
|
|
|
type: new GraphQLList(Alias),
|
|
|
|
|
resolve: (source, args, { lookupLoader }, info) => {
|
|
|
|
|
const key = 'aliases'
|
|
|
|
|
if (key in source) {
|
|
|
|
|
return source[key]
|
|
|
|
|
} else {
|
|
|
|
|
const { entityType, id } = source
|
|
|
|
|
const params = { inc: ['aliases'] }
|
|
|
|
|
return lookupLoader.load([entityType, id, params]).then(entity => {
|
|
|
|
|
return entity[key]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2016-08-08 07:54:06 +00:00
|
|
|
country: { type: GraphQLString },
|
2016-08-20 05:59:32 +00:00
|
|
|
area: { type: Area },
|
|
|
|
|
beginArea: {
|
|
|
|
|
type: Area,
|
|
|
|
|
resolve: getFallback(['begin-area', 'begin_area'])
|
|
|
|
|
},
|
|
|
|
|
endArea: {
|
|
|
|
|
type: Area,
|
|
|
|
|
resolve: getFallback(['end-area', 'end_area'])
|
|
|
|
|
},
|
|
|
|
|
lifeSpan,
|
2016-08-08 07:54:06 +00:00
|
|
|
...fieldWithID('gender'),
|
|
|
|
|
...fieldWithID('type'),
|
2016-08-20 05:59:32 +00:00
|
|
|
recordings,
|
|
|
|
|
releases,
|
|
|
|
|
releaseGroups,
|
|
|
|
|
works,
|
|
|
|
|
relations
|
2016-08-08 07:54:06 +00:00
|
|
|
})
|
|
|
|
|
})
|
2016-08-20 05:59:32 +00:00
|
|
|
|
|
|
|
|
export const ArtistPage = createPageType(Artist)
|
|
|
|
|
export default Artist
|