From 9601b400b5c68f615bf3c11b7cceda0d92124300 Mon Sep 17 00:00:00 2001 From: Brian Beck Date: Mon, 12 Dec 2016 00:34:26 -0800 Subject: [PATCH] Give every entity a collections field (#13) --- src/types/area.js | 2 ++ src/types/artist.js | 2 ++ src/types/collection.js | 4 +++ src/types/event.js | 2 ++ src/types/helpers.js | 6 ++++ src/types/instrument.js | 2 ++ src/types/label.js | 2 ++ src/types/place.js | 2 ++ src/types/recording.js | 2 ++ src/types/release-group.js | 2 ++ src/types/release.js | 2 ++ src/types/series.js | 2 ++ src/types/work.js | 2 ++ .../215ca91efacd4b7a1e7800813c8382e0.headers | 10 +++--- .../fixtures/456168a862ec0ca28127f067e3f166e7 | Bin 277 -> 282 bytes .../456168a862ec0ca28127f067e3f166e7.headers | 12 +++---- .../fixtures/5818a7c5bffe034297462ee69620f3f3 | Bin 0 -> 397 bytes .../5818a7c5bffe034297462ee69620f3f3.headers | 29 +++++++++++++++ .../fixtures/8069a2ac06a7b48528fa1350e0e45e71 | Bin 0 -> 677 bytes .../8069a2ac06a7b48528fa1350e0e45e71.headers | 29 +++++++++++++++ .../fixtures/83ae719cb34d0210568c345deed9cfff | Bin 287 -> 288 bytes .../83ae719cb34d0210568c345deed9cfff.headers | 12 +++---- .../fixtures/a60002a456739daaf792c25859deda09 | Bin 0 -> 439 bytes .../a60002a456739daaf792c25859deda09.headers | 29 +++++++++++++++ test/schema.js | 34 ++++++++++++++++++ 25 files changed, 170 insertions(+), 17 deletions(-) create mode 100644 test/fixtures/5818a7c5bffe034297462ee69620f3f3 create mode 100644 test/fixtures/5818a7c5bffe034297462ee69620f3f3.headers create mode 100644 test/fixtures/8069a2ac06a7b48528fa1350e0e45e71 create mode 100644 test/fixtures/8069a2ac06a7b48528fa1350e0e45e71.headers create mode 100644 test/fixtures/a60002a456739daaf792c25859deda09 create mode 100644 test/fixtures/a60002a456739daaf792c25859deda09.headers 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 52102fcbee7bed6d3927255d35d17535cf17d848..4d53d0858214d2f57f0666141876ed4a6e2515f4 100644 GIT binary patch literal 282 zcmV+#0p_L2y#}K(o~>IO@VQyK`2&1 zO{=^%#;BSrvL8hH?#6kF(vL2{AfIXWK0EYrW+&^(?ei-m+Ism^wwq{p}g|NETJ+dsE{14o$j-yZ@10Peah#P3A{=Qh6SoB@Bz2pxe@t40KkFfv#w#G!5<` zfRz=8y?`+Lh?6?garUu#3Q&M?L7lZ5Ru$cx;7?L9j`SA2n~(iJ+=a;n=)S%S7*ej! zS@E(Y?%mJp0(pt<(dE`*doZ~LK6AO}-=Xv*RHZU~qibxqwkWh9Je@cp8Oe27_l(&- zHFit3&B?D{f0F&G_Wt)D*ZM$$SGKkd>e?{mf*X{YH`ubKY^}Ar6*~9orBRGTiP|uU b!W?3<;wp`{u1>YoO2YmNT`>#`9|8aX(`|}9 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 0000000000000000000000000000000000000000..630caa310e09de714e60a89d725143bc1b81eea2 GIT binary patch literal 397 zcmV;80doEyiwFP!0000018tH$ZyPZThW|>z`3UHIx)0x0pksj!9a13hz>|265Lt31 zozuYZe=n8BS(;7a$IFMWbcMv8DKqkgL&-2dUcpjfm|>?{g>8#%4-HUag82&0N~YiS zR&zUHXO+UPUG_-*v>>&5pnW@7o>u9xF4Jjo$Bl}MLHZAu_A`e`v!h*ZC(Rj}$K_4o?fT^TcCeJYB1Nro&BYrCDIhpb z31adEY*A5Bp*HI%y*D%A_CZN5_(TR=W)Buq1acIipw?FBYAy5K1L^*72jcql>L|QD zE&^l=`2pUo3f(1+xZE%>SrZlIAXReU$OoW68Imcrwt*~Ve!w7`kOOB2x~&SVDGbSH z4;5SEig30n-ZOajz2|bWTuoiRWwD1gg>+QlV}!RvcpQh(DYu~#JR0ZGLS`*gbWuPU z9Mni526jxDp2&>7(mxFSg_yBA%NZh*mGx-@pwby^^jgGB)z`GkxOCIF`a1K){aU`@ zimSzZU=eIOrr`l2e0y)iIrBW7yuI=4k&XdPTdZoyIrB}5e<7%k^m3r_SEW!W&qHZ#@w5B_Ze|9Hzu zE@-qii@ZV9mXL|s7$LQCGGj|V9};heFkW7a5-5@3GO9l$a8GL+tl4V1T+>aUA4Y_~ z;kX|9`N98o8~Fo^_W!fN8e6${;u(@;BS$%jJ{Aa(s6~TllW(p+@BZx|$7W)Ir>=hj L0KCa=2?ziH^DseN literal 0 HcmV?d00001 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 7c3f685b28300eb0f553fac866bc90afc83a6246..825efadda8c7921023fa154098a08ae7a3f65176 100644 GIT binary patch literal 288 zcmV+*0pI=~iwFP!000001C^0YPQx$|g|8BMovAYMPvh=Tk=Vcq5Q~XDmLih4iVad# z^)M`1aEe|GQ?-Zranv%ypNPvTb0+S4KGs$>uWHw_VK{T^(oA( zWoGVU+JuRftarJul;o0p4aQjw!pbUFsKIoq+By_mG%|C|obukq0I_6g*%O>3x*Ex& zQs9)VffGv5vT=akZ;j&uYtvgQ9q)nEd)S#OL+Bh$#$|)(>`8&cvIO zW$tN8eOllPK3~F)<>7C{Z{s_fM>7?>Fz!R7IkJEJ@H+<0%b#HH^Wb6G-Nua#<0W0a l72c8+K-N?sI!~YtH$V!F(cEIAI(B?Iegd!=*uC5V002pikC*@e 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 0000000000000000000000000000000000000000..dc5bbef1782d0ed7b8df2d4477779fccd30bfdf7 GIT binary patch literal 439 zcmV;o0Z9HIiwFP!0000019ehOi`y^|{VPG|3`ib*=D2hzlokp-mQwUF$_h4iu$@D? zdMifI^UxZ%ER#e6;z zJa&k3{L}Xva&;lC3WOGFjvllQ0aDJMgO!{w@vqgAQ65hHJf8UmNBKA7UCa;L&8OiZ z_WkA?r8vzkE;=7uC76!9W}z&avC0_<(n06Bo@n0|h01zL7#^Kr5<{DnF5|60!OcIva0%Txl=Y0lYP}xm(+|V|yMe$)9pM hpi;|xwW)tQUrJr)tX9S?#ebz { + 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) +})