diff --git a/src/types/area.js b/src/types/area.js index d38c314..2b010d0 100644 --- a/src/types/area.js +++ b/src/types/area.js @@ -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 }) }) diff --git a/src/types/artist.js b/src/types/artist.js index 9ec6fb8..bae5365 100644 --- a/src/types/artist.js +++ b/src/types/artist.js @@ -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 }) }) diff --git a/src/types/collection.js b/src/types/collection.js index d4d2bba..7cd13e5 100644 --- a/src/types/collection.js +++ b/src/types/collection.js @@ -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 }) }) diff --git a/src/types/event.js b/src/types/event.js index 5e799f2..95a206e 100644 --- a/src/types/event.js +++ b/src/types/event.js @@ -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 }) }) diff --git a/src/types/helpers.js b/src/types/helpers.js index ea2cf60..f2243b2 100644 --- a/src/types/helpers.js +++ b/src/types/helpers.js @@ -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, diff --git a/src/types/instrument.js b/src/types/instrument.js index 20786ef..f2ee29e 100644 --- a/src/types/instrument.js +++ b/src/types/instrument.js @@ -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 }) }) diff --git a/src/types/label.js b/src/types/label.js index fca312b..465158f 100644 --- a/src/types/label.js +++ b/src/types/label.js @@ -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 }) }) diff --git a/src/types/place.js b/src/types/place.js index f7caf64..5de70e7 100644 --- a/src/types/place.js +++ b/src/types/place.js @@ -13,6 +13,7 @@ import { events, fieldWithID, relationships, + collections, tags, connectionWithExtras } from './helpers' @@ -64,6 +65,7 @@ function.` }), events, relationships, + collections, tags }) }) diff --git a/src/types/recording.js b/src/types/recording.js index 1c6174c..a8c2e30 100644 --- a/src/types/recording.js +++ b/src/types/recording.js @@ -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 }) }) diff --git a/src/types/release-group.js b/src/types/release-group.js index 9b36db2..4e100e7 100644 --- a/src/types/release-group.js +++ b/src/types/release-group.js @@ -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 }) }) diff --git a/src/types/release.js b/src/types/release.js index 7f4f0e4..dd60f91 100644 --- a/src/types/release.js +++ b/src/types/release.js @@ -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 }) }) diff --git a/src/types/series.js b/src/types/series.js index d7062e0..335dc2c 100644 --- a/src/types/series.js +++ b/src/types/series.js @@ -7,6 +7,7 @@ import { name, disambiguation, relationships, + collections, tags, fieldWithID, connectionWithExtras @@ -28,6 +29,7 @@ theme.`, contains.` }), relationships, + collections, tags }) }) diff --git a/src/types/work.js b/src/types/work.js index 7c5c211..fa36133 100644 --- a/src/types/work.js +++ b/src/types/work.js @@ -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 }) }) diff --git a/test/fixtures/215ca91efacd4b7a1e7800813c8382e0.headers b/test/fixtures/215ca91efacd4b7a1e7800813c8382e0.headers index 1b8baac..5842c03 100644 --- a/test/fixtures/215ca91efacd4b7a1e7800813c8382e0.headers +++ b/test/fixtures/215ca91efacd4b7a1e7800813c8382e0.headers @@ -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" diff --git a/test/fixtures/456168a862ec0ca28127f067e3f166e7 b/test/fixtures/456168a862ec0ca28127f067e3f166e7 index 52102fc..4d53d08 100644 Binary files a/test/fixtures/456168a862ec0ca28127f067e3f166e7 and b/test/fixtures/456168a862ec0ca28127f067e3f166e7 differ diff --git a/test/fixtures/456168a862ec0ca28127f067e3f166e7.headers b/test/fixtures/456168a862ec0ca28127f067e3f166e7.headers index eaef6b6..09bfd52 100644 --- a/test/fixtures/456168a862ec0ca28127f067e3f166e7.headers +++ b/test/fixtures/456168a862ec0ca28127f067e3f166e7.headers @@ -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" diff --git a/test/fixtures/5818a7c5bffe034297462ee69620f3f3 b/test/fixtures/5818a7c5bffe034297462ee69620f3f3 new file mode 100644 index 0000000..630caa3 Binary files /dev/null and b/test/fixtures/5818a7c5bffe034297462ee69620f3f3 differ diff --git a/test/fixtures/5818a7c5bffe034297462ee69620f3f3.headers b/test/fixtures/5818a7c5bffe034297462ee69620f3f3.headers new file mode 100644 index 0000000..5633baf --- /dev/null +++ b/test/fixtures/5818a7c5bffe034297462ee69620f3f3.headers @@ -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" + } + } +} \ No newline at end of file diff --git a/test/fixtures/8069a2ac06a7b48528fa1350e0e45e71 b/test/fixtures/8069a2ac06a7b48528fa1350e0e45e71 new file mode 100644 index 0000000..f62323f Binary files /dev/null and b/test/fixtures/8069a2ac06a7b48528fa1350e0e45e71 differ diff --git a/test/fixtures/8069a2ac06a7b48528fa1350e0e45e71.headers b/test/fixtures/8069a2ac06a7b48528fa1350e0e45e71.headers new file mode 100644 index 0000000..bb70e4f --- /dev/null +++ b/test/fixtures/8069a2ac06a7b48528fa1350e0e45e71.headers @@ -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" + } + } +} \ No newline at end of file diff --git a/test/fixtures/83ae719cb34d0210568c345deed9cfff b/test/fixtures/83ae719cb34d0210568c345deed9cfff index 7c3f685..825efad 100644 Binary files a/test/fixtures/83ae719cb34d0210568c345deed9cfff and b/test/fixtures/83ae719cb34d0210568c345deed9cfff differ diff --git a/test/fixtures/83ae719cb34d0210568c345deed9cfff.headers b/test/fixtures/83ae719cb34d0210568c345deed9cfff.headers index 1fc707c..0115840 100644 --- a/test/fixtures/83ae719cb34d0210568c345deed9cfff.headers +++ b/test/fixtures/83ae719cb34d0210568c345deed9cfff.headers @@ -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" diff --git a/test/fixtures/a60002a456739daaf792c25859deda09 b/test/fixtures/a60002a456739daaf792c25859deda09 new file mode 100644 index 0000000..dc5bbef Binary files /dev/null and b/test/fixtures/a60002a456739daaf792c25859deda09 differ diff --git a/test/fixtures/a60002a456739daaf792c25859deda09.headers b/test/fixtures/a60002a456739daaf792c25859deda09.headers new file mode 100644 index 0000000..5f8b318 --- /dev/null +++ b/test/fixtures/a60002a456739daaf792c25859deda09.headers @@ -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" + } + } +} \ No newline at end of file diff --git a/test/schema.js b/test/schema.js index 27ed87f..dff9d7d 100644 --- a/test/schema.js +++ b/test/schema.js @@ -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) +})