Give every entity a collections field (#13)

This commit is contained in:
Brian Beck 2016-12-12 00:34:26 -08:00 committed by GitHub
parent c2f7d9b836
commit 9601b400b5
25 changed files with 170 additions and 17 deletions

View file

@ -14,6 +14,7 @@ import {
places,
releases,
relationships,
collections,
tags,
connectionWithExtras
} from './helpers'
@ -42,6 +43,7 @@ the codes assigned by ISO to countries and subdivisions.`,
places,
releases,
relationships,
collections,
tags
})
})

View file

@ -18,6 +18,7 @@ import {
releaseGroups,
works,
relationships,
collections,
tags,
connectionWithExtras
} from './helpers'
@ -82,6 +83,7 @@ neither. Groups do not have genders.`
releaseGroups,
works,
relationships,
collections,
tags
})
})

View file

@ -12,11 +12,13 @@ import {
areas,
artists,
events,
instruments,
labels,
places,
recordings,
releases,
releaseGroups,
series,
works,
fieldWithID,
resolveHyphenated,
@ -47,11 +49,13 @@ lists of entities that users can create.`,
areas,
artists,
events,
instruments,
labels,
places,
recordings,
releases,
releaseGroups,
series,
works
})
})

View file

@ -11,6 +11,7 @@ import {
aliases,
lifeSpan,
relationships,
collections,
tags,
connectionWithExtras
} from './helpers'
@ -46,6 +47,7 @@ for syntax and examples.`
description: 'What kind of event the event is, e.g. concert, festival, etc.'
}),
relationships,
collections,
tags
})
})

View file

@ -20,7 +20,9 @@ import Alias from './alias'
import ArtistCredit from './artist-credit'
import { AreaConnection } from './area'
import { ArtistConnection } from './artist'
import { CollectionConnection } from './collection'
import { EventConnection } from './event'
import { InstrumentConnection } from './instrument'
import { LabelConnection } from './label'
import LifeSpan from './life-span'
import { PlaceConnection } from './place'
@ -28,6 +30,7 @@ import { RecordingConnection } from './recording'
import { RelationshipConnection } from './relationship'
import { ReleaseConnection } from './release'
import { ReleaseGroupConnection } from './release-group'
import { SeriesConnection } from './series'
import { TagConnection } from './tag'
import { WorkConnection } from './work'
import {
@ -224,7 +227,9 @@ export const releaseStatus = {
export const areas = linkedQuery(AreaConnection)
export const artists = linkedQuery(ArtistConnection)
export const collections = linkedQuery(CollectionConnection)
export const events = linkedQuery(EventConnection)
export const instruments = linkedQuery(InstrumentConnection)
export const labels = linkedQuery(LabelConnection)
export const places = linkedQuery(PlaceConnection)
export const recordings = linkedQuery(RecordingConnection)
@ -239,6 +244,7 @@ export const releaseGroups = linkedQuery(ReleaseGroupConnection, {
type: releaseGroupType
}
})
export const series = linkedQuery(SeriesConnection)
export const tags = linkedQuery(TagConnection, {
resolve: createSubqueryResolver({}, (value = [], args) => ({
totalCount: value.length,

View file

@ -9,6 +9,7 @@ import {
disambiguation,
aliases,
relationships,
collections,
tags,
connectionWithExtras
} from './helpers'
@ -36,6 +37,7 @@ created, similar to the [Hornbostel-Sachs](https://en.wikipedia.org/wiki/Hornbos
classification.`
}),
relationships,
collections,
tags
})
})

View file

@ -18,6 +18,7 @@ import {
lifeSpan,
releases,
relationships,
collections,
tags,
fieldWithID,
connectionWithExtras
@ -61,6 +62,7 @@ imprint, production, distributor, rights society, etc.`
}),
releases,
relationships,
collections,
tags
})
})

View file

@ -13,6 +13,7 @@ import {
events,
fieldWithID,
relationships,
collections,
tags,
connectionWithExtras
} from './helpers'
@ -64,6 +65,7 @@ function.`
}),
events,
relationships,
collections,
tags
})
})

View file

@ -17,6 +17,7 @@ import {
artists,
releases,
relationships,
collections,
tags,
connectionWithExtras
} from './helpers'
@ -61,6 +62,7 @@ from the lengths of the tracks using it.`
artists,
releases,
relationships,
collections,
tags
})
})

View file

@ -14,6 +14,7 @@ import {
artists,
releases,
relationships,
collections,
tags,
fieldWithID,
resolveHyphenated,
@ -59,6 +60,7 @@ that apply to this release group.`
artists,
releases,
relationships,
collections,
tags
})
})

View file

@ -17,6 +17,7 @@ import {
recordings,
releaseGroups,
relationships,
collections,
tags,
fieldWithID,
resolveHyphenated,
@ -86,6 +87,7 @@ It is not a mark of how good or bad the music itself is for that, use
recordings,
releaseGroups,
relationships,
collections,
tags
})
})

View file

@ -7,6 +7,7 @@ import {
name,
disambiguation,
relationships,
collections,
tags,
fieldWithID,
connectionWithExtras
@ -28,6 +29,7 @@ theme.`,
contains.`
}),
relationships,
collections,
tags
})
})

View file

@ -9,6 +9,7 @@ import {
aliases,
artists,
relationships,
collections,
tags,
fieldWithID,
connectionWithExtras
@ -40,6 +41,7 @@ to the work by copyright collecting agencies.`
}),
artists,
relationships,
collections,
tags
})
})

View file

@ -1,24 +1,24 @@
{
"statusCode": 400,
"headers": {
"date": "Fri, 09 Dec 2016 21:53:05 GMT",
"date": "Mon, 12 Dec 2016 07:56:05 GMT",
"content-type": "application/json; charset=utf-8",
"content-length": "72",
"connection": "keep-alive",
"keep-alive": "timeout=15",
"x-ratelimit-limit": "700",
"x-ratelimit-remaining": "429",
"x-ratelimit-reset": "1481320386",
"x-ratelimit-remaining": "312",
"x-ratelimit-reset": "1481529365",
"server": "Plack::Handler::Starlet",
"etag": "\"d54d2bc5c412c1bb3c02bfc91d13a900\"",
"access-control-allow-origin": "*"
},
"url": "http://musicbrainz.org:80/ws/2/artist/5b11f4ce-a62d-471e-81fc-a69a8278c7da?inc=foobar&fmt=json",
"time": 396,
"time": 866,
"request": {
"method": "GET",
"headers": {
"User-Agent": "graphbrainz/3.1.1 ( https://github.com/exogen/graphbrainz )",
"User-Agent": "graphbrainz/4.3.1 ( https://github.com/exogen/graphbrainz )",
"host": "musicbrainz.org",
"accept-encoding": "gzip, deflate",
"accept": "application/json"

Binary file not shown.

View file

@ -1,26 +1,26 @@
{
"statusCode": 200,
"headers": {
"date": "Fri, 09 Dec 2016 21:53:05 GMT",
"date": "Mon, 12 Dec 2016 07:56:05 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": "368",
"x-ratelimit-reset": "1481320386",
"x-ratelimit-remaining": "311",
"x-ratelimit-reset": "1481529365",
"server": "Plack::Handler::Starlet",
"etag": "W/\"05d3a423b0b8ea0f99c184f8131c7cac\"",
"etag": "W/\"f00ea1ebebe6936096608c45118d0e3b\"",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/artist/c8da2e40-bd28-4d4e-813a-bd2f51958ba8?fmt=json",
"time": 419,
"time": 887,
"request": {
"method": "GET",
"headers": {
"User-Agent": "graphbrainz/3.1.1 ( https://github.com/exogen/graphbrainz )",
"User-Agent": "graphbrainz/4.3.1 ( 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": "Mon, 12 Dec 2016 07:59:23 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": "685",
"x-ratelimit-reset": "1481529565",
"server": "Plack::Handler::Starlet",
"etag": "W/\"2e87369b3c2ea4068ed4a2f8b732b3df\"",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/release/0702057c-cb90-43d3-b7b4-6d0cc37e8644?fmt=json",
"time": 1086,
"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"
}
}
}

Binary file not shown.

View file

@ -0,0 +1,29 @@
{
"statusCode": 200,
"headers": {
"date": "Mon, 12 Dec 2016 07:59:24 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": "512",
"x-ratelimit-reset": "1481529565",
"server": "Plack::Handler::Starlet",
"etag": "W/\"27dbff9a8f2f1b787d979f3a28fb285f\"",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/collection?release=0702057c-cb90-43d3-b7b4-6d0cc37e8644&fmt=json",
"time": 790,
"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"
}
}
}

Binary file not shown.

View file

@ -1,26 +1,26 @@
{
"statusCode": 200,
"headers": {
"date": "Mon, 12 Dec 2016 02:59:36 GMT",
"date": "Mon, 12 Dec 2016 07:59:24 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": "547",
"x-ratelimit-reset": "1481511578",
"x-ratelimit-remaining": "514",
"x-ratelimit-reset": "1481529565",
"server": "Plack::Handler::Starlet",
"etag": "W/\"c9830e30ce33960f506234d5af63ad79\"",
"etag": "W/\"1cbd0e6b12cd298d7ef5dccf9f1866b6\"",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/collection?artist=24f1766e-9635-4d58-a4d4-9413f9f98a4c&fmt=json",
"time": 516,
"time": 785,
"request": {
"method": "GET",
"headers": {
"User-Agent": "graphbrainz/4.2.0 ( https://github.com/exogen/graphbrainz )",
"User-Agent": "graphbrainz/4.3.1 ( 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": "Mon, 12 Dec 2016 07:59:23 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": "687",
"x-ratelimit-reset": "1481529565",
"server": "Plack::Handler::Starlet",
"etag": "W/\"cbab3698166993cb186c48208c553225\"",
"access-control-allow-origin": "*",
"content-encoding": "gzip"
},
"url": "http://musicbrainz.org:80/ws/2/artist/24f1766e-9635-4d58-a4d4-9413f9f98a4c?fmt=json",
"time": 1061,
"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"
}
}
}

View file

@ -651,3 +651,37 @@ test('Collections can be looked up by MBID', testData, `
t.is(collection.name, 'Beets Music Collection')
t.is(collection.releases.edges.length, 25)
})
test('entities have a collections field', testData, `
{
lookup {
release(mbid: "0702057c-cb90-43d3-b7b4-6d0cc37e8644") {
title
collections {
totalCount
edges {
node {
editor
}
}
}
}
artist(mbid: "24f1766e-9635-4d58-a4d4-9413f9f98a4c") {
name
collections {
totalCount
edges {
node {
editor
}
}
}
}
}
}
`, (t, data) => {
const { release, artist } = data.lookup
t.true(release.collections.totalCount > 0)
t.true(release.collections.edges.length > 0)
t.true(artist.collections.edges.length > 0)
})