Use Duration scalar for recording lengths (#11)

This commit is contained in:
Brian Beck 2016-12-11 16:12:54 -08:00 committed by GitHub
parent c4c023c750
commit 0600c2026b
4 changed files with 43 additions and 3 deletions

View file

@ -1,12 +1,11 @@
import {
GraphQLObjectType,
GraphQLList,
GraphQLInt,
GraphQLBoolean
} from 'graphql/type'
import Node from './node'
import Entity from './entity'
import { ISRC } from './scalars'
import { Duration, ISRC } from './scalars'
import {
id,
mbid,
@ -51,7 +50,7 @@ or mixing.`,
(ISRCs) for this recording.`
},
length: {
type: GraphQLInt,
type: Duration,
description: `An approximation to the length of the recording, calculated
from the lengths of the tracks using it.`
},

View file

@ -0,0 +1 @@
{"disambiguation":"","id":"9f9cf187-d6f9-437f-9d98-d59cdbd52757","video":false,"length":383493,"title":"Paranoid Android"}

View file

@ -0,0 +1,27 @@
{
"statusCode": 200,
"headers": {
"date": "Sun, 11 Dec 2016 22:49:10 GMT",
"content-type": "application/json; charset=utf-8",
"content-length": "122",
"connection": "keep-alive",
"keep-alive": "timeout=15",
"x-ratelimit-limit": "700",
"x-ratelimit-remaining": "535",
"x-ratelimit-reset": "1481496552",
"server": "Plack::Handler::Starlet",
"etag": "\"6a43a7029600ae595783f39d6d3d1f63\"",
"access-control-allow-origin": "*"
},
"url": "http://musicbrainz.org:80/ws/2/recording/9f9cf187-d6f9-437f-9d98-d59cdbd52757?fmt=json",
"time": 424,
"request": {
"method": "GET",
"headers": {
"User-Agent": "graphbrainz/4.2.0 ( https://github.com/exogen/graphbrainz )",
"host": "musicbrainz.org",
"accept-encoding": "gzip, deflate",
"accept": "application/json"
}
}
}

View file

@ -579,3 +579,16 @@ test('Works can be browsed by iswc', testData, `
{ title: 'Song of the French Partisan', iswcs: ['T-900.755.682-3'] }
])
})
test('Recordings have a length in milliseconds', testData, `
{
lookup {
recording(mbid: "9f9cf187-d6f9-437f-9d98-d59cdbd52757") {
length
}
}
}
`, (t, data) => {
const { recording } = data.lookup
t.is(recording.length, 383493)
})