mirror of
https://github.com/BradNut/graphbrainz
synced 2025-09-08 17:40:32 +00:00
Add support for release media (#14)
This commit is contained in:
parent
ae9330f1d0
commit
d906ec1086
9 changed files with 278 additions and 0 deletions
|
|
@ -987,6 +987,31 @@ type LookupQuery {
|
||||||
# 36-character UUIDs.
|
# 36-character UUIDs.
|
||||||
scalar MBID
|
scalar MBID
|
||||||
|
|
||||||
|
# A medium is the actual physical medium the audio content is
|
||||||
|
# stored upon. This means that each CD in a multi-disc release will be entered as
|
||||||
|
# separate mediums within the release, and that both sides of a vinyl record or
|
||||||
|
# cassette will exist on one medium. Mediums have a format (e.g. CD, DVD, vinyl,
|
||||||
|
# cassette) and can optionally also have a title.
|
||||||
|
type Medium {
|
||||||
|
# The title of this particular medium.
|
||||||
|
title: String
|
||||||
|
|
||||||
|
# The [format](https://musicbrainz.org/doc/Release/Format) of
|
||||||
|
# the medium (e.g. CD, DVD, vinyl, cassette).
|
||||||
|
format: String
|
||||||
|
|
||||||
|
# The MBID associated with the value of the `format`
|
||||||
|
# field.
|
||||||
|
formatID: MBID
|
||||||
|
|
||||||
|
# The order of this medium in the release (for example, in a
|
||||||
|
# multi-disc release).
|
||||||
|
position: Int
|
||||||
|
|
||||||
|
# The number of audio tracks on this medium.
|
||||||
|
trackCount: Int
|
||||||
|
}
|
||||||
|
|
||||||
# An object with an ID
|
# An object with an ID
|
||||||
interface Node {
|
interface Node {
|
||||||
# The id of the object.
|
# The id of the object.
|
||||||
|
|
@ -1551,6 +1576,9 @@ type Release implements Node, Entity {
|
||||||
# [ratings](https://musicbrainz.org/doc/Rating_System).
|
# [ratings](https://musicbrainz.org/doc/Rating_System).
|
||||||
quality: String
|
quality: String
|
||||||
|
|
||||||
|
# The media on which the release was distributed.
|
||||||
|
media: [Medium]
|
||||||
|
|
||||||
# A list of artists linked to this entity.
|
# A list of artists linked to this entity.
|
||||||
artists(after: String, first: Int): ArtistConnection
|
artists(after: String, first: Int): ArtistConnection
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ You may also be interested in reading the [schema in GraphQL syntax](schema.md).
|
||||||
<li>[LabelEdge](#labeledge)</li>
|
<li>[LabelEdge](#labeledge)</li>
|
||||||
<li>[LifeSpan](#lifespan)</li>
|
<li>[LifeSpan](#lifespan)</li>
|
||||||
<li>[LookupQuery](#lookupquery)</li>
|
<li>[LookupQuery](#lookupquery)</li>
|
||||||
|
<li>[Medium](#medium)</li>
|
||||||
<li>[PageInfo](#pageinfo)</li>
|
<li>[PageInfo](#pageinfo)</li>
|
||||||
<li>[Place](#place)</li>
|
<li>[Place](#place)</li>
|
||||||
<li>[PlaceConnection](#placeconnection)</li>
|
<li>[PlaceConnection](#placeconnection)</li>
|
||||||
|
|
@ -2503,6 +2504,61 @@ A lookup of an individual MusicBrainz entity by its MBID.
|
||||||
</tr>
|
</tr>
|
||||||
</tbody></table>
|
</tbody></table>
|
||||||
|
|
||||||
|
### Medium
|
||||||
|
|
||||||
|
A medium is the actual physical medium the audio content is
|
||||||
|
stored upon. This means that each CD in a multi-disc release will be entered as
|
||||||
|
separate mediums within the release, and that both sides of a vinyl record or
|
||||||
|
cassette will exist on one medium. Mediums have a format (e.g. CD, DVD, vinyl,
|
||||||
|
cassette) and can optionally also have a title.
|
||||||
|
|
||||||
|
<table><thead>
|
||||||
|
<tr>
|
||||||
|
<th align="left">Field / Argument</th>
|
||||||
|
<th align="left">Type</th>
|
||||||
|
<th align="left">Description</th>
|
||||||
|
</tr>
|
||||||
|
</thead><tbody>
|
||||||
|
<tr>
|
||||||
|
<td valign="top"><strong>title</strong> </td>
|
||||||
|
<td valign="top"><a href="#string">String</a></td>
|
||||||
|
<td>
|
||||||
|
The title of this particular medium.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td valign="top"><strong>format</strong> </td>
|
||||||
|
<td valign="top"><a href="#string">String</a></td>
|
||||||
|
<td>
|
||||||
|
The <a href="https://musicbrainz.org/doc/Release/Format">format</a> of
|
||||||
|
the medium (e.g. CD, DVD, vinyl, cassette).
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td valign="top"><strong>formatID</strong> </td>
|
||||||
|
<td valign="top"><a href="#mbid">MBID</a></td>
|
||||||
|
<td>
|
||||||
|
The MBID associated with the value of the <code>format</code>
|
||||||
|
field.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td valign="top"><strong>position</strong> </td>
|
||||||
|
<td valign="top"><a href="#int">Int</a></td>
|
||||||
|
<td>
|
||||||
|
The order of this medium in the release (for example, in a
|
||||||
|
multi-disc release).
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td valign="top"><strong>trackCount</strong> </td>
|
||||||
|
<td valign="top"><a href="#int">Int</a></td>
|
||||||
|
<td>
|
||||||
|
The number of audio tracks on this medium.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody></table>
|
||||||
|
|
||||||
### PageInfo
|
### PageInfo
|
||||||
|
|
||||||
Information about pagination in a connection.
|
Information about pagination in a connection.
|
||||||
|
|
@ -3877,6 +3933,13 @@ It is not a mark of how good or bad the music itself is – for that, use
|
||||||
<a href="https://musicbrainz.org/doc/Rating_System">ratings</a>.
|
<a href="https://musicbrainz.org/doc/Rating_System">ratings</a>.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td valign="top"><strong>media</strong> </td>
|
||||||
|
<td valign="top">[<a href="#medium">Medium</a>]</td>
|
||||||
|
<td>
|
||||||
|
The media on which the release was distributed.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top"><strong>artists</strong> </td>
|
<td valign="top"><strong>artists</strong> </td>
|
||||||
<td valign="top"><a href="#artistconnection">ArtistConnection</a></td>
|
<td valign="top"><a href="#artistconnection">ArtistConnection</a></td>
|
||||||
|
|
|
||||||
87
schema.json
87
schema.json
|
|
@ -2911,6 +2911,22 @@
|
||||||
"isDeprecated": false,
|
"isDeprecated": false,
|
||||||
"deprecationReason": null
|
"deprecationReason": null
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "media",
|
||||||
|
"description": "The media on which the release was distributed.",
|
||||||
|
"args": [],
|
||||||
|
"type": {
|
||||||
|
"kind": "LIST",
|
||||||
|
"name": null,
|
||||||
|
"ofType": {
|
||||||
|
"kind": "OBJECT",
|
||||||
|
"name": "Medium",
|
||||||
|
"ofType": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"isDeprecated": false,
|
||||||
|
"deprecationReason": null
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "artists",
|
"name": "artists",
|
||||||
"description": "A list of artists linked to this entity.",
|
"description": "A list of artists linked to this entity.",
|
||||||
|
|
@ -3197,6 +3213,77 @@
|
||||||
"enumValues": null,
|
"enumValues": null,
|
||||||
"possibleTypes": null
|
"possibleTypes": null
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"kind": "OBJECT",
|
||||||
|
"name": "Medium",
|
||||||
|
"description": "A medium is the actual physical medium the audio content is\nstored upon. This means that each CD in a multi-disc release will be entered as\nseparate mediums within the release, and that both sides of a vinyl record or\ncassette will exist on one medium. Mediums have a format (e.g. CD, DVD, vinyl,\ncassette) and can optionally also have a title.",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"name": "title",
|
||||||
|
"description": "The title of this particular medium.",
|
||||||
|
"args": [],
|
||||||
|
"type": {
|
||||||
|
"kind": "SCALAR",
|
||||||
|
"name": "String",
|
||||||
|
"ofType": null
|
||||||
|
},
|
||||||
|
"isDeprecated": false,
|
||||||
|
"deprecationReason": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "format",
|
||||||
|
"description": "The [format](https://musicbrainz.org/doc/Release/Format) of\nthe medium (e.g. CD, DVD, vinyl, cassette).",
|
||||||
|
"args": [],
|
||||||
|
"type": {
|
||||||
|
"kind": "SCALAR",
|
||||||
|
"name": "String",
|
||||||
|
"ofType": null
|
||||||
|
},
|
||||||
|
"isDeprecated": false,
|
||||||
|
"deprecationReason": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "formatID",
|
||||||
|
"description": "The MBID associated with the value of the `format`\nfield.",
|
||||||
|
"args": [],
|
||||||
|
"type": {
|
||||||
|
"kind": "SCALAR",
|
||||||
|
"name": "MBID",
|
||||||
|
"ofType": null
|
||||||
|
},
|
||||||
|
"isDeprecated": false,
|
||||||
|
"deprecationReason": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "position",
|
||||||
|
"description": "The order of this medium in the release (for example, in a\nmulti-disc release).",
|
||||||
|
"args": [],
|
||||||
|
"type": {
|
||||||
|
"kind": "SCALAR",
|
||||||
|
"name": "Int",
|
||||||
|
"ofType": null
|
||||||
|
},
|
||||||
|
"isDeprecated": false,
|
||||||
|
"deprecationReason": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "trackCount",
|
||||||
|
"description": "The number of audio tracks on this medium.",
|
||||||
|
"args": [],
|
||||||
|
"type": {
|
||||||
|
"kind": "SCALAR",
|
||||||
|
"name": "Int",
|
||||||
|
"ofType": null
|
||||||
|
},
|
||||||
|
"isDeprecated": false,
|
||||||
|
"deprecationReason": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"inputFields": null,
|
||||||
|
"interfaces": [],
|
||||||
|
"enumValues": null,
|
||||||
|
"possibleTypes": null
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"kind": "OBJECT",
|
"kind": "OBJECT",
|
||||||
"name": "LabelConnection",
|
"name": "LabelConnection",
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ export function includeSubqueries (params, info, fragments = info.fragments) {
|
||||||
artistCredit: 'artist-credits',
|
artistCredit: 'artist-credits',
|
||||||
artistCredits: 'artist-credits',
|
artistCredits: 'artist-credits',
|
||||||
isrcs: 'isrcs',
|
isrcs: 'isrcs',
|
||||||
|
media: 'media',
|
||||||
tags: 'tags'
|
tags: 'tags'
|
||||||
}
|
}
|
||||||
let fields = getFields(info, fragments)
|
let fields = getFields(info, fragments)
|
||||||
|
|
|
||||||
31
src/types/media.js
Normal file
31
src/types/media.js
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
import { GraphQLObjectType, GraphQLString, GraphQLInt } from 'graphql/type'
|
||||||
|
import { resolveHyphenated, fieldWithID } from './helpers'
|
||||||
|
|
||||||
|
export default new GraphQLObjectType({
|
||||||
|
name: 'Medium',
|
||||||
|
description: `A medium is the actual physical medium the audio content is
|
||||||
|
stored upon. This means that each CD in a multi-disc release will be entered as
|
||||||
|
separate mediums within the release, and that both sides of a vinyl record or
|
||||||
|
cassette will exist on one medium. Mediums have a format (e.g. CD, DVD, vinyl,
|
||||||
|
cassette) and can optionally also have a title.`,
|
||||||
|
fields: () => ({
|
||||||
|
title: {
|
||||||
|
type: GraphQLString,
|
||||||
|
description: 'The title of this particular medium.'
|
||||||
|
},
|
||||||
|
...fieldWithID('format', {
|
||||||
|
description: `The [format](https://musicbrainz.org/doc/Release/Format) of
|
||||||
|
the medium (e.g. CD, DVD, vinyl, cassette).`
|
||||||
|
}),
|
||||||
|
position: {
|
||||||
|
type: GraphQLInt,
|
||||||
|
description: `The order of this medium in the release (for example, in a
|
||||||
|
multi-disc release).`
|
||||||
|
},
|
||||||
|
trackCount: {
|
||||||
|
type: GraphQLInt,
|
||||||
|
description: 'The number of audio tracks on this medium.',
|
||||||
|
resolve: resolveHyphenated
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
@ -2,6 +2,7 @@ import { GraphQLObjectType, GraphQLString, GraphQLList } from 'graphql/type'
|
||||||
import Node from './node'
|
import Node from './node'
|
||||||
import Entity from './entity'
|
import Entity from './entity'
|
||||||
import { ASIN, DateType } from './scalars'
|
import { ASIN, DateType } from './scalars'
|
||||||
|
import Media from './media'
|
||||||
import { ReleaseStatus } from './enums'
|
import { ReleaseStatus } from './enums'
|
||||||
import ReleaseEvent from './release-event'
|
import ReleaseEvent from './release-event'
|
||||||
import {
|
import {
|
||||||
|
|
@ -82,6 +83,10 @@ information.`
|
||||||
It is not a mark of how good or bad the music itself is – for that, use
|
It is not a mark of how good or bad the music itself is – for that, use
|
||||||
[ratings](https://musicbrainz.org/doc/Rating_System).`
|
[ratings](https://musicbrainz.org/doc/Rating_System).`
|
||||||
},
|
},
|
||||||
|
media: {
|
||||||
|
type: new GraphQLList(Media),
|
||||||
|
description: 'The media on which the release was distributed.'
|
||||||
|
},
|
||||||
artists,
|
artists,
|
||||||
labels,
|
labels,
|
||||||
recordings,
|
recordings,
|
||||||
|
|
|
||||||
BIN
test/fixtures/f70e148191e1ebbc95eb12ddc2d85be2
vendored
Normal file
BIN
test/fixtures/f70e148191e1ebbc95eb12ddc2d85be2
vendored
Normal file
Binary file not shown.
29
test/fixtures/f70e148191e1ebbc95eb12ddc2d85be2.headers
vendored
Normal file
29
test/fixtures/f70e148191e1ebbc95eb12ddc2d85be2.headers
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"statusCode": 200,
|
||||||
|
"headers": {
|
||||||
|
"date": "Mon, 12 Dec 2016 08:53:41 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": "287",
|
||||||
|
"x-ratelimit-reset": "1481532821",
|
||||||
|
"server": "Plack::Handler::Starlet",
|
||||||
|
"etag": "W/\"87b80866564432cc2d6a470811edc6a8\"",
|
||||||
|
"access-control-allow-origin": "*",
|
||||||
|
"content-encoding": "gzip"
|
||||||
|
},
|
||||||
|
"url": "http://musicbrainz.org:80/ws/2/release/a4864e94-6d75-4ade-bc93-0dabf3521453?inc=media&fmt=json",
|
||||||
|
"time": 506,
|
||||||
|
"request": {
|
||||||
|
"method": "GET",
|
||||||
|
"headers": {
|
||||||
|
"User-Agent": "graphbrainz/4.3.1 ( https://github.com/exogen/graphbrainz )",
|
||||||
|
"host": "musicbrainz.org",
|
||||||
|
"accept-encoding": "gzip, deflate",
|
||||||
|
"accept": "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -685,3 +685,37 @@ test('entities have a collections field', testData, `
|
||||||
t.true(release.collections.edges.length > 0)
|
t.true(release.collections.edges.length > 0)
|
||||||
t.true(artist.collections.edges.length > 0)
|
t.true(artist.collections.edges.length > 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('Releases support a list of media', testData, `
|
||||||
|
{
|
||||||
|
lookup {
|
||||||
|
release(mbid: "a4864e94-6d75-4ade-bc93-0dabf3521453") {
|
||||||
|
media {
|
||||||
|
title
|
||||||
|
format
|
||||||
|
formatID
|
||||||
|
position
|
||||||
|
trackCount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`, (t, data) => {
|
||||||
|
const { release } = data.lookup
|
||||||
|
t.deepEqual(release.media, [
|
||||||
|
{
|
||||||
|
title: 'Left',
|
||||||
|
format: 'CD',
|
||||||
|
formatID: '9712d52a-4509-3d4b-a1a2-67c88c643e31',
|
||||||
|
position: 1,
|
||||||
|
trackCount: 12
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Right',
|
||||||
|
format: 'CD',
|
||||||
|
formatID: '9712d52a-4509-3d4b-a1a2-67c88c643e31',
|
||||||
|
position: 2,
|
||||||
|
trackCount: 11
|
||||||
|
}
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue