Rename artistCredit fields to artistCredits (#9)

* Rename artistCredit field to artistCredits
* Update deprecation rendering
This commit is contained in:
Brian Beck 2016-12-11 12:32:58 -08:00 committed by GitHub
parent fdac30b999
commit b2ec20ed2c
17 changed files with 1782 additions and 827 deletions

View file

@ -947,7 +947,10 @@ type Recording implements Node, Entity {
aliases: [Alias]
# The main credited artist(s).
artistCredit: [ArtistCredit]
artistCredit: [ArtistCredit] @deprecated(reason: "The `artistCredit` field has been renamed to\\n`artistCredits`, since it is a list of credits and is referred to in the\\nplural form throughout the MusicBrainz documentation. This field is deprecated\\nand will be removed in a major release in the future. Use the equivalent\\n`artistCredits` field.")
# The main credited artist(s).
artistCredits: [ArtistCredit]
# An approximation to the length of the recording, calculated
# from the lengths of the tracks using it.
@ -1316,7 +1319,10 @@ type Release implements Node, Entity {
aliases: [Alias]
# The main credited artist(s).
artistCredit: [ArtistCredit]
artistCredit: [ArtistCredit] @deprecated(reason: "The `artistCredit` field has been renamed to\\n`artistCredits`, since it is a list of credits and is referred to in the\\nplural form throughout the MusicBrainz documentation. This field is deprecated\\nand will be removed in a major release in the future. Use the equivalent\\n`artistCredits` field.")
# The main credited artist(s).
artistCredits: [ArtistCredit]
# The release events for this release.
releaseEvents: [ReleaseEvent]
@ -1444,7 +1450,10 @@ type ReleaseGroup implements Node, Entity {
aliases: [Alias]
# The main credited artist(s).
artistCredit: [ArtistCredit]
artistCredit: [ArtistCredit] @deprecated(reason: "The `artistCredit` field has been renamed to\\n`artistCredits`, since it is a list of credits and is referred to in the\\nplural form throughout the MusicBrainz documentation. This field is deprecated\\nand will be removed in a major release in the future. Use the equivalent\\n`artistCredits` field.")
# The main credited artist(s).
artistCredits: [ArtistCredit]
# The date of the earliest release in the group.
firstReleaseDate: Date

File diff suppressed because it is too large Load diff

View file

@ -2012,6 +2012,22 @@
"ofType": null
}
},
"isDeprecated": true,
"deprecationReason": "The `artistCredit` field has been renamed to\n`artistCredits`, since it is a list of credits and is referred to in the\nplural form throughout the MusicBrainz documentation. This field is deprecated\nand will be removed in a major release in the future. Use the equivalent\n`artistCredits` field."
},
{
"name": "artistCredits",
"description": "The main credited artist(s).",
"args": [],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "ArtistCredit",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
@ -2580,6 +2596,22 @@
"ofType": null
}
},
"isDeprecated": true,
"deprecationReason": "The `artistCredit` field has been renamed to\n`artistCredits`, since it is a list of credits and is referred to in the\nplural form throughout the MusicBrainz documentation. This field is deprecated\nand will be removed in a major release in the future. Use the equivalent\n`artistCredits` field."
},
{
"name": "artistCredits",
"description": "The main credited artist(s).",
"args": [],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "ArtistCredit",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
@ -4979,6 +5011,22 @@
"ofType": null
}
},
"isDeprecated": true,
"deprecationReason": "The `artistCredit` field has been renamed to\n`artistCredits`, since it is a list of credits and is referred to in the\nplural form throughout the MusicBrainz documentation. This field is deprecated\nand will be removed in a major release in the future. Use the equivalent\n`artistCredits` field."
},
{
"name": "artistCredits",
"description": "The main credited artist(s).",
"args": [],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "ArtistCredit",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},

View file

@ -54,9 +54,15 @@ function renderObject (type, { skipTitle = false } = {}) {
console.log('</thead><tbody>')
type.fields.forEach(field => {
console.log(' <tr>')
console.log(` <td valign="top"><strong>${field.name}</strong></td>`)
console.log(` <td valign="top"><strong>${field.name}</strong> ${field.isDeprecated ? '⚠️' : ''}</td>`)
console.log(` <td valign="top">${markdown(renderType(field.type))}</td>`)
console.log(` <td>${markdown(field.description)}</td>`)
console.log(` <td>`)
console.log(` ${markdown(field.description)}`)
if (field.isDeprecated) {
console.log(' <br/><br/><p>⚠️ <strong>DEPRECATED</strong></p>')
console.log(` <blockquote>${markdown(field.deprecationReason)}</blockquote>`)
}
console.log(' </td>')
console.log(' </tr>')
if (field.args.length) {
field.args.forEach((arg, i) => {
@ -129,8 +135,14 @@ enums.forEach(type => {
console.log('</thead><tbody>')
type.enumValues.forEach(value => {
console.log(' <tr>')
console.log(` <td valign="top"><strong>${value.name}</strong></td>`)
console.log(` <td>${markdown(value.description)}</td>`)
console.log(` <td valign="top"><strong>${value.name}</strong> ${value.isDeprecated ? '⚠️' : ''}</td>`)
console.log(' <td>')
console.log(` ${markdown(value.description)}`)
if (value.isDeprecated) {
console.log(' <br/><br/><p>⚠️ <strong>DEPRECATED</strong></p>')
console.log(` <blockquote>${markdown(value.deprecationReason)}</blockquote>`)
}
console.log(' </td>')
console.log(' </tr>')
})
console.log('</tbody></table>')

View file

@ -40,6 +40,7 @@ export function includeSubqueries (params, info, fragments = info.fragments) {
const subqueryIncludes = {
aliases: 'aliases',
artistCredit: 'artist-credits',
artistCredits: 'artist-credits',
tags: 'tags'
}
let fields = getFields(info, fragments)
@ -177,15 +178,15 @@ export function resolveLinked (entity, args, context, info) {
* for a particular field that's being requested, make another request to grab
* it (after making sure it isn't already available).
*/
export function createSubqueryResolver (includeValue, handler = value => value) {
export function createSubqueryResolver ({ inc, key } = {}, handler = value => value) {
return (entity, args, { loaders }, info) => {
const key = toDashed(info.fieldName)
key = key || toDashed(info.fieldName)
let promise
if (key in entity || (entity._inc && entity._inc.indexOf(key) >= 0)) {
promise = Promise.resolve(entity)
} else {
const { _type: entityType, id } = entity
const params = { inc: [includeValue || key] }
const params = { inc: [inc || key] }
promise = loaders.lookup.load([entityType, id, params])
}
return promise.then(entity => handler(entity[key], args))

View file

@ -30,7 +30,7 @@ track, etc.`
type: GraphQLString,
description: `Join phrases might include words and/or punctuation to
separate artist names as they appear on the release, track, etc.`,
resolve: data => data['joinphrase']
resolve: data => data.joinphrase
}
})
})

View file

@ -55,6 +55,22 @@ export function toWords (name) {
})
}
export function resolveHyphenated (obj, args, context, info) {
const name = toDashed(info.fieldName)
return obj[name]
}
export function resolveWithFallback (keys) {
return (obj) => {
for (let i = 0; i < keys.length; i++) {
const key = keys[i]
if (key in obj) {
return obj[key]
}
}
}
}
export function fieldWithID (name, config = {}) {
config = {
type: GraphQLString,
@ -77,22 +93,6 @@ field.`,
}
}
export function resolveHyphenated (obj, args, context, info) {
const name = dashify(info.fieldName)
return obj[name]
}
export function resolveWithFallback (keys) {
return (obj) => {
for (let i = 0; i < keys.length; i++) {
const key = keys[i]
if (key in obj) {
return obj[key]
}
}
}
}
export const id = globalIdField()
export const mbid = {
type: new GraphQLNonNull(MBID),
@ -196,10 +196,19 @@ alternate names or misspellings.`,
resolve: createSubqueryResolver()
}
export const artistCredit = {
export const artistCredits = {
type: new GraphQLList(ArtistCredit),
description: 'The main credited artist(s).',
resolve: createSubqueryResolver()
resolve: createSubqueryResolver({ key: 'artist-credit' })
}
export const artistCredit = {
...artistCredits,
deprecationReason: `The \`artistCredit\` field has been renamed to
\`artistCredits\`, since it is a list of credits and is referred to in the
plural form throughout the MusicBrainz documentation. This field is deprecated
and will be removed in a major release in the future. Use the equivalent
\`artistCredits\` field.`
}
export const releaseGroupType = {
@ -229,7 +238,7 @@ export const releaseGroups = linkedQuery(ReleaseGroupConnection, {
}
})
export const tags = linkedQuery(TagConnection, {
resolve: createSubqueryResolver('tags', (value = [], args) => ({
resolve: createSubqueryResolver({}, (value = [], args) => ({
totalCount: value.length,
...connectionFromArray(value, args)
}))

View file

@ -8,6 +8,7 @@ import {
disambiguation,
aliases,
artistCredit,
artistCredits,
artists,
releases,
relationships,
@ -37,6 +38,7 @@ or mixing.`,
disambiguation,
aliases,
artistCredit,
artistCredits,
length: {
type: GraphQLInt,
description: `An approximation to the length of the recording, calculated

View file

@ -10,6 +10,7 @@ import {
disambiguation,
aliases,
artistCredit,
artistCredits,
artists,
releases,
relationships,
@ -37,6 +38,7 @@ album it doesnt matter how many CDs or editions/versions it had.`,
disambiguation,
aliases,
artistCredit,
artistCredits,
firstReleaseDate: {
type: DateType,
description: 'The date of the earliest release in the group.',

View file

@ -11,6 +11,7 @@ import {
disambiguation,
aliases,
artistCredit,
artistCredits,
artists,
labels,
recordings,
@ -37,6 +38,7 @@ MusicBrainz as one release.`,
disambiguation,
aliases,
artistCredit,
artistCredits,
releaseEvents: {
type: new GraphQLList(ReleaseEvent),
description: 'The release events for this release.',

Binary file not shown.

View file

@ -0,0 +1,29 @@
{
"statusCode": 200,
"headers": {
"date": "Sun, 11 Dec 2016 19:09:42 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"keep-alive": "timeout=15",
"vary": "Accept-Encoding",
"x-ratelimit-limit": "700",
"x-ratelimit-remaining": "436",
"x-ratelimit-reset": "1481483383",
"server": "Plack::Handler::Starlet",
"etag": "W/\"54c3ce0c0b89068301c6398acc373f1d\"",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/recording/07649758-09c8-4d70-bc6f-5c37ab36334d?inc=artist-credits&fmt=json",
"time": 415,
"request": {
"method": "GET",
"headers": {
"User-Agent": "graphbrainz/4.1.0 ( https://github.com/exogen/graphbrainz )",
"host": "musicbrainz.org",
"accept-encoding": "gzip, deflate",
"accept": "application/json"
}
}
}

Binary file not shown.

View file

@ -0,0 +1,29 @@
{
"statusCode": 200,
"headers": {
"date": "Sun, 11 Dec 2016 19:09:42 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"keep-alive": "timeout=15",
"vary": "Accept-Encoding",
"x-ratelimit-limit": "700",
"x-ratelimit-remaining": "434",
"x-ratelimit-reset": "1481483383",
"server": "Plack::Handler::Starlet",
"etag": "W/\"75e29d38d42caac97bdac8d6b2ea2212\"",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/release-group/53614893-6f25-4519-9cae-b1db904e2887?inc=artist-credits&fmt=json",
"time": 418,
"request": {
"method": "GET",
"headers": {
"User-Agent": "graphbrainz/4.1.0 ( https://github.com/exogen/graphbrainz )",
"host": "musicbrainz.org",
"accept-encoding": "gzip, deflate",
"accept": "application/json"
}
}
}

Binary file not shown.

View file

@ -0,0 +1,29 @@
{
"statusCode": 200,
"headers": {
"date": "Sun, 11 Dec 2016 19:09:42 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "keep-alive",
"keep-alive": "timeout=15",
"vary": "Accept-Encoding",
"x-ratelimit-limit": "700",
"x-ratelimit-remaining": "439",
"x-ratelimit-reset": "1481483383",
"server": "Plack::Handler::Starlet",
"etag": "W/\"8a9ee65e910a0be7a5dcfa7974758c30\"",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/release/d5cdb7fd-c7e9-460a-9549-8a369655cc52?inc=artist-credits&fmt=json",
"time": 418,
"request": {
"method": "GET",
"headers": {
"User-Agent": "graphbrainz/4.1.0 ( https://github.com/exogen/graphbrainz )",
"host": "musicbrainz.org",
"accept-encoding": "gzip, deflate",
"accept": "application/json"
}
}
}

View file

@ -479,3 +479,59 @@ test('Artists have a list of ISNIs and IPIs', testData,
t.deepEqual(artist.ipis, ['00006457004'])
t.deepEqual(artist.isnis, ['0000000110273481'])
})
test('artistCredits is an alias for artistCredit', testData,
`
{
lookup {
recording(mbid: "07649758-09c8-4d70-bc6f-5c37ab36334d") {
artistCredit {
name
joinPhrase
}
artistCredits {
name
joinPhrase
}
}
release(mbid: "d5cdb7fd-c7e9-460a-9549-8a369655cc52") {
artistCredit {
name
joinPhrase
}
artistCredits {
name
joinPhrase
}
}
releaseGroup(mbid: "53614893-6f25-4519-9cae-b1db904e2887") {
artistCredit {
name
joinPhrase
}
artistCredits {
name
joinPhrase
}
}
}
}
`, (t, data) => {
const { recording, release, releaseGroup } = data.lookup
t.deepEqual(recording.artistCredit, [
{ name: 'Holly Golightly', joinPhrase: ' & ' },
{ name: 'The Brokeoffs', joinPhrase: '' }
])
t.deepEqual(recording.artistCredits, recording.artistCredit)
t.deepEqual(release.artistCredit, [
{ name: 'Leonard Cohen', joinPhrase: '' }
])
t.deepEqual(release.artistCredits, release.artistCredit)
t.deepEqual(releaseGroup.artistCredit, [
{ name: 'DJ Muggs', joinPhrase: ' vs. ' },
{ name: 'Ill Bill', joinPhrase: '' }
])
t.deepEqual(releaseGroup.artistCredits, releaseGroup.artistCredit)
})