From 75e24c18bce30c81ee6eb42c40981e8e265a4b0e Mon Sep 17 00:00:00 2001 From: Brian Beck Date: Sat, 4 Nov 2017 15:32:05 -0700 Subject: [PATCH] Add missing Area type/typeID, pass start() options to middleware (#46) --- docs/schema.md | 8 ++++ docs/types.md | 20 ++++++++ package.json | 1 - schema.json | 24 ++++++++++ src/api/client.js | 8 ++-- src/extensions/cover-art-archive/index.js | 4 +- src/extensions/fanart-tv/index.js | 5 +- src/extensions/fanart-tv/loader.js | 1 + src/extensions/mediawiki/index.js | 5 +- src/extensions/the-audio-db/index.js | 5 +- src/index.js | 4 +- src/types/area.js | 5 ++ src/types/helpers.js | 9 +++- .../fixtures/0e70a8c76fbbaf74403b1979f99fbdeb | Bin 0 -> 217 bytes .../0e70a8c76fbbaf74403b1979f99fbdeb.headers | 29 ++++++++++++ .../fixtures/756130058c8775fa7cb29d1dd73b0466 | 1 + .../756130058c8775fa7cb29d1dd73b0466.headers | 27 +++++++++++ .../fixtures/761c6577dcc6cfe15f0c2143f6c6dfd1 | 1 + .../761c6577dcc6cfe15f0c2143f6c6dfd1.headers | 27 +++++++++++ .../fixtures/7c1e7fa42910da45f700bc832c12f126 | 1 + .../7c1e7fa42910da45f700bc832c12f126.headers | 27 +++++++++++ .../fixtures/89450a383b06d3be5d7cf6f7c7234721 | Bin 0 -> 1343 bytes .../89450a383b06d3be5d7cf6f7c7234721.headers | 29 ++++++++++++ .../fixtures/d191cb9a3134c90cfaa98b8b73f9e8c9 | 1 + .../d191cb9a3134c90cfaa98b8b73f9e8c9.headers | 27 +++++++++++ test/schema.js | 16 +++++++ test/snapshots/schema.js.md | 43 ++++++++++++++++++ test/snapshots/schema.js.snap | Bin 0 -> 491 bytes 28 files changed, 310 insertions(+), 18 deletions(-) create mode 100644 test/fixtures/0e70a8c76fbbaf74403b1979f99fbdeb create mode 100644 test/fixtures/0e70a8c76fbbaf74403b1979f99fbdeb.headers create mode 100644 test/fixtures/756130058c8775fa7cb29d1dd73b0466 create mode 100644 test/fixtures/756130058c8775fa7cb29d1dd73b0466.headers create mode 100644 test/fixtures/761c6577dcc6cfe15f0c2143f6c6dfd1 create mode 100644 test/fixtures/761c6577dcc6cfe15f0c2143f6c6dfd1.headers create mode 100644 test/fixtures/7c1e7fa42910da45f700bc832c12f126 create mode 100644 test/fixtures/7c1e7fa42910da45f700bc832c12f126.headers create mode 100644 test/fixtures/89450a383b06d3be5d7cf6f7c7234721 create mode 100644 test/fixtures/89450a383b06d3be5d7cf6f7c7234721.headers create mode 100644 test/fixtures/d191cb9a3134c90cfaa98b8b73f9e8c9 create mode 100644 test/fixtures/d191cb9a3134c90cfaa98b8b73f9e8c9.headers create mode 100644 test/snapshots/schema.js.md create mode 100644 test/snapshots/schema.js.snap diff --git a/docs/schema.md b/docs/schema.md index 895e9a8..f59fe7d 100644 --- a/docs/schema.md +++ b/docs/schema.md @@ -58,6 +58,14 @@ type Area implements Node, Entity { # the codes assigned by ISO to countries and subdivisions. isoCodes: [String] + # The type of area (country, city, etc. – see the [possible + # values](https://musicbrainz.org/doc/Area)). + type: String + + # The MBID associated with the value of the `type` + # field. + typeID: MBID + # A list of artists linked to this entity. artists(after: String, first: Int): ArtistConnection diff --git a/docs/types.md b/docs/types.md index 1f2c835..9768c31 100644 --- a/docs/types.md +++ b/docs/types.md @@ -317,6 +317,26 @@ alternate names or misspellings. [ISO 3166 codes](https://en.wikipedia.org/wiki/ISO_3166) are the codes assigned by ISO to countries and subdivisions. + + + +type +String + + +The type of area (country, city, etc. – see the [possible +values](https://musicbrainz.org/doc/Area)). + + + + +typeID +MBID + + +The MBID associated with the value of the `type` +field. + diff --git a/package.json b/package.json index 459e0fd..c6efb3d 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,6 @@ "dashify": "^0.2.2", "dataloader": "^1.3.0", "debug": "^3.0.0", - "deep-diff": "^0.3.8", "dotenv": "^4.0.0", "es6-error": "^4.0.2", "express": "^4.16.2", diff --git a/schema.json b/schema.json index 348c6fb..3377450 100644 --- a/schema.json +++ b/schema.json @@ -591,6 +591,30 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "type", + "description": "The type of area (country, city, etc. – see the [possible\nvalues](https://musicbrainz.org/doc/Area)).", + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "typeID", + "description": "The MBID associated with the value of the `type`\nfield.", + "args": [], + "type": { + "kind": "SCALAR", + "name": "MBID", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "artists", "description": "A list of artists linked to this entity.", diff --git a/src/api/client.js b/src/api/client.js index 01d7a9d..87c4ea3 100644 --- a/src/api/client.js +++ b/src/api/client.js @@ -97,15 +97,17 @@ export default class Client { } } - debug(`Sending request. url=${this.baseURL}${path} attempt=${info.currentAttempt}`) + const url = `${options.baseUrl}${options.url}` + + debug(`Sending request. url=${url} attempt=${info.currentAttempt}`) request(options, (err, response, body) => { if (err) { - debug(`Error: “${err}” url=${this.baseURL}${path}`) + debug(`Error: “${err}” url=${url}`) reject(err) } else if (response.statusCode >= 400) { const message = this.parseErrorMessage(response, body) - debug(`Error: “${message}” url=${this.baseURL}${path}`) + debug(`Error: “${message}” url=${url}`) const ClientError = this.errorClass reject(new ClientError(message, response.statusCode)) } else if (options.method === 'HEAD') { diff --git a/src/extensions/cover-art-archive/index.js b/src/extensions/cover-art-archive/index.js index 228ac4f..4523c36 100644 --- a/src/extensions/cover-art-archive/index.js +++ b/src/extensions/cover-art-archive/index.js @@ -6,8 +6,8 @@ import { ONE_DAY } from '../../util' export default { name: 'Cover Art Archive', - description: - 'Retrieve cover art images for releases from the [Cover Art Archive](https://coverartarchive.org/).', + description: `Retrieve cover art images for releases from the [Cover Art +Archive](https://coverartarchive.org/).`, extendContext (context, { coverArtClient, coverArtArchive = {} } = {}) { const client = coverArtClient || new CoverArtArchiveClient(coverArtArchive) const cacheSize = parseInt( diff --git a/src/extensions/fanart-tv/index.js b/src/extensions/fanart-tv/index.js index bfcbf8f..bfeecb4 100644 --- a/src/extensions/fanart-tv/index.js +++ b/src/extensions/fanart-tv/index.js @@ -6,9 +6,8 @@ import { ONE_DAY } from '../../util' export default { name: 'fanart.tv', - description: - 'Retrieve high quality artwork for artists, releases, and labels from ' + - '[fanart.tv](https://fanart.tv/).', + description: `Retrieve high quality artwork for artists, releases, and labels +from [fanart.tv](https://fanart.tv/).`, extendContext (context, { fanArt = {} } = {}) { const client = new FanArtClient(fanArt) const cacheSize = parseInt( diff --git a/src/extensions/fanart-tv/loader.js b/src/extensions/fanart-tv/loader.js index 4da6855..ce04486 100644 --- a/src/extensions/fanart-tv/loader.js +++ b/src/extensions/fanart-tv/loader.js @@ -47,5 +47,6 @@ export default function createLoader (options) { cacheKeyFn: ([ entityType, id ]) => `${entityType}/${id}`, cacheMap: cache }) + return loader } diff --git a/src/extensions/mediawiki/index.js b/src/extensions/mediawiki/index.js index d7f72f9..bc58d40 100644 --- a/src/extensions/mediawiki/index.js +++ b/src/extensions/mediawiki/index.js @@ -6,9 +6,8 @@ import { ONE_DAY } from '../../util' export default { name: 'MediaWiki', - description: - 'Retrieve information from MediaWiki image pages, like the actual image ' + - 'file URL and EXIF metadata.', + description: `Retrieve information from MediaWiki image pages, like the actual +image file URL and EXIF metadata.`, extendContext (context, { mediaWiki = {} } = {}) { const client = new MediaWikiClient(mediaWiki) const cacheSize = parseInt( diff --git a/src/extensions/the-audio-db/index.js b/src/extensions/the-audio-db/index.js index ba1c26a..a6fb611 100644 --- a/src/extensions/the-audio-db/index.js +++ b/src/extensions/the-audio-db/index.js @@ -6,9 +6,8 @@ import { ONE_DAY } from '../../util' export default { name: 'TheAudioDB', - description: - 'Retrieve images and information about artists, releases, and recordings ' + - 'from [TheAudioDB.com](http://www.theaudiodb.com/).', + description: `Retrieve images and information about artists, releases, and +recordings from [TheAudioDB.com](http://www.theaudiodb.com/).`, extendContext (context, { theAudioDB = {} } = {}) { const client = new TheAudioDBClient(theAudioDB) const cacheSize = parseInt( diff --git a/src/index.js b/src/index.js index cac7831..bf0ce6b 100644 --- a/src/index.js +++ b/src/index.js @@ -52,7 +52,7 @@ const middleware = ({ export default middleware -export function start () { +export function start (options) { require('dotenv').config({ silent: true }) const app = express() const port = process.env.PORT || 3000 @@ -72,7 +72,7 @@ export function start () { break } app.use(compression()) - app.use(route, cors(corsOptions), middleware()) + app.use(route, cors(corsOptions), middleware(options)) app.listen(port) console.log(`Listening on port ${port}.`) } diff --git a/src/types/area.js b/src/types/area.js index 2b010d0..1ecf2d0 100644 --- a/src/types/area.js +++ b/src/types/area.js @@ -16,6 +16,7 @@ import { relationships, collections, tags, + fieldWithID, connectionWithExtras } from './helpers' @@ -37,6 +38,10 @@ or settlements (countries, cities, or the like).`, the codes assigned by ISO to countries and subdivisions.`, resolve: data => data['iso-3166-1-codes'] }, + ...fieldWithID('type', { + description: `The type of area (country, city, etc. – see the [possible +values](https://musicbrainz.org/doc/Area)).` + }), artists, events, labels, diff --git a/src/types/helpers.js b/src/types/helpers.js index f8a8131..e666cdb 100644 --- a/src/types/helpers.js +++ b/src/types/helpers.js @@ -90,7 +90,14 @@ export function fieldWithID (name, config = {}) { type: isPlural ? new GraphQLList(MBID) : MBID, description: `The MBID${s} associated with the value${s} of the \`${name}\` field.`, - resolve: resolveHyphenated + resolve: (entity, args, { loaders }) => { + const fieldName = toDashed(idName) + if (fieldName in entity) { + return entity[fieldName] + } + return loaders.lookup.load([entity._type, entity.id]) + .then(data => data[fieldName]) + } } return { [name]: config, diff --git a/test/fixtures/0e70a8c76fbbaf74403b1979f99fbdeb b/test/fixtures/0e70a8c76fbbaf74403b1979f99fbdeb new file mode 100644 index 0000000000000000000000000000000000000000..6a7b52787bd5aadaa0b113f76ddcaea62878bc5a GIT binary patch literal 217 zcmV;~04Dz*iwFP!0000019gtEZo@DPM1Q5=Yyy%k%Td-i$S)KqI#4DZ2&k>Vl7}G3 zzgNnVE**Kidv_05X%RTWnNt3^$hOdWhXz85*lBCA!zr>PIDWx6j%WC8Am48_afVi%!7SR%=8$Od;kr`}aV^B+PI1fl z&&*oNP7Pksgstn#;Deo!T4T|+-1o!ah(s6fPnZSMjSBSvva*zH-garg%Qe(4?TjnN T@_QXl!SneG38$7=AprmYJELly literal 0 HcmV?d00001 diff --git a/test/fixtures/0e70a8c76fbbaf74403b1979f99fbdeb.headers b/test/fixtures/0e70a8c76fbbaf74403b1979f99fbdeb.headers new file mode 100644 index 0000000..89c663c --- /dev/null +++ b/test/fixtures/0e70a8c76fbbaf74403b1979f99fbdeb.headers @@ -0,0 +1,29 @@ +{ + "statusCode": 200, + "headers": { + "date": "Sat, 04 Nov 2017 22:18:56 GMT", + "content-type": "application/json; charset=utf-8", + "transfer-encoding": "chunked", + "connection": "keep-alive", + "keep-alive": "timeout=15", + "vary": "Accept-Encoding", + "x-ratelimit-limit": "1200", + "x-ratelimit-remaining": "1049", + "x-ratelimit-reset": "1509833937", + "server": "Plack::Handler::Starlet", + "etag": "W/\"f3dbfd2359a7a02668094286e405c7d7\"", + "access-control-allow-origin": "*", + "content-encoding": "gzip" + }, + "url": "http://musicbrainz.org:80/ws/2/area/d907b0ac-2956-386f-a246-62d55779aae1?fmt=json", + "time": 355, + "request": { + "method": "GET", + "headers": { + "User-Agent": "graphbrainz/7.0.0 ( 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/756130058c8775fa7cb29d1dd73b0466 b/test/fixtures/756130058c8775fa7cb29d1dd73b0466 new file mode 100644 index 0000000..8d967d6 --- /dev/null +++ b/test/fixtures/756130058c8775fa7cb29d1dd73b0466 @@ -0,0 +1 @@ +{"type":"City","disambiguation":"","type-id":"6fd8f29a-3d0a-32fc-980d-ea697b69da78","sort-name":"New Germany","life-span":{"end":null,"ended":false,"begin":null},"name":"New Germany","id":"36721201-bb7c-4dce-be68-0553b1131205"} \ No newline at end of file diff --git a/test/fixtures/756130058c8775fa7cb29d1dd73b0466.headers b/test/fixtures/756130058c8775fa7cb29d1dd73b0466.headers new file mode 100644 index 0000000..c683061 --- /dev/null +++ b/test/fixtures/756130058c8775fa7cb29d1dd73b0466.headers @@ -0,0 +1,27 @@ +{ + "statusCode": 200, + "headers": { + "date": "Sat, 04 Nov 2017 22:19:01 GMT", + "content-type": "application/json; charset=utf-8", + "content-length": "227", + "connection": "keep-alive", + "keep-alive": "timeout=15", + "x-ratelimit-limit": "1200", + "x-ratelimit-remaining": "789", + "x-ratelimit-reset": "1509833941", + "server": "Plack::Handler::Starlet", + "etag": "\"f003dc5379faf397737ab63975fcacab\"", + "access-control-allow-origin": "*" + }, + "url": "http://musicbrainz.org:80/ws/2/area/36721201-bb7c-4dce-be68-0553b1131205?fmt=json", + "time": 356, + "request": { + "method": "GET", + "headers": { + "User-Agent": "graphbrainz/7.0.0 ( 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/761c6577dcc6cfe15f0c2143f6c6dfd1 b/test/fixtures/761c6577dcc6cfe15f0c2143f6c6dfd1 new file mode 100644 index 0000000..b717ae5 --- /dev/null +++ b/test/fixtures/761c6577dcc6cfe15f0c2143f6c6dfd1 @@ -0,0 +1 @@ +{"type-id":"6fd8f29a-3d0a-32fc-980d-ea697b69da78","life-span":{"ended":false,"begin":null,"end":null},"type":"City","id":"84a30f29-682f-4642-a981-4ba0f50a42fa","sort-name":"Brakel","name":"Brakel","disambiguation":""} \ No newline at end of file diff --git a/test/fixtures/761c6577dcc6cfe15f0c2143f6c6dfd1.headers b/test/fixtures/761c6577dcc6cfe15f0c2143f6c6dfd1.headers new file mode 100644 index 0000000..f239cff --- /dev/null +++ b/test/fixtures/761c6577dcc6cfe15f0c2143f6c6dfd1.headers @@ -0,0 +1,27 @@ +{ + "statusCode": 200, + "headers": { + "date": "Sat, 04 Nov 2017 22:19:01 GMT", + "content-type": "application/json; charset=utf-8", + "content-length": "217", + "connection": "keep-alive", + "keep-alive": "timeout=15", + "x-ratelimit-limit": "1200", + "x-ratelimit-remaining": "787", + "x-ratelimit-reset": "1509833941", + "server": "Plack::Handler::Starlet", + "etag": "\"313b6eef3c187e7f009395a2511cb6bc\"", + "access-control-allow-origin": "*" + }, + "url": "http://musicbrainz.org:80/ws/2/area/84a30f29-682f-4642-a981-4ba0f50a42fa?fmt=json", + "time": 365, + "request": { + "method": "GET", + "headers": { + "User-Agent": "graphbrainz/7.0.0 ( 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/7c1e7fa42910da45f700bc832c12f126 b/test/fixtures/7c1e7fa42910da45f700bc832c12f126 new file mode 100644 index 0000000..973635b --- /dev/null +++ b/test/fixtures/7c1e7fa42910da45f700bc832c12f126 @@ -0,0 +1 @@ +{"id":"516dda4c-c58d-43a7-9bde-ef6b12a8b741","type-id":"6fd8f29a-3d0a-32fc-980d-ea697b69da78","life-span":{"ended":false,"end":null,"begin":null},"name":"New Germany","sort-name":"New Germany","disambiguation":"","type":"City"} \ No newline at end of file diff --git a/test/fixtures/7c1e7fa42910da45f700bc832c12f126.headers b/test/fixtures/7c1e7fa42910da45f700bc832c12f126.headers new file mode 100644 index 0000000..e8cd095 --- /dev/null +++ b/test/fixtures/7c1e7fa42910da45f700bc832c12f126.headers @@ -0,0 +1,27 @@ +{ + "statusCode": 200, + "headers": { + "date": "Sat, 04 Nov 2017 22:19:01 GMT", + "content-type": "application/json; charset=utf-8", + "content-length": "227", + "connection": "keep-alive", + "keep-alive": "timeout=15", + "x-ratelimit-limit": "1200", + "x-ratelimit-remaining": "788", + "x-ratelimit-reset": "1509833941", + "server": "Plack::Handler::Starlet", + "etag": "\"fd49c850b3796ed9dc7cfdb680d6142d\"", + "access-control-allow-origin": "*" + }, + "url": "http://musicbrainz.org:80/ws/2/area/516dda4c-c58d-43a7-9bde-ef6b12a8b741?fmt=json", + "time": 365, + "request": { + "method": "GET", + "headers": { + "User-Agent": "graphbrainz/7.0.0 ( 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/89450a383b06d3be5d7cf6f7c7234721 b/test/fixtures/89450a383b06d3be5d7cf6f7c7234721 new file mode 100644 index 0000000000000000000000000000000000000000..323bae21c753945814df1328e195aaa4c1f5fb19 GIT binary patch literal 1343 zcmV-F1;F|riwFP!000001Kn7=lG`>E{S^&sAwz)ROP%et-KDTSNhX;sE*@MnqR0(N zt!KxxMf@m|Ns~wCDl=}}B-tY4%qE@`+jBo+<9tT|QW7CbD=E8Dic}IVE^rR+1#l1X z)Z)2>QVMHe5gYpmV`S4u1P=%uknn>ra6YyA7SG0MX$>guTUitpQvJ947O0_xHTdkQ z73=YV>$@ZpfUv_UaxgfEN$Db6x}4$2#R7zyt2{oG%KMI+UQs(SkKDG6msz2qT^escBeycdh-tmBf)m#UZ5D;Hf23q1TpHM3p_X5w?*{tS;fD4A)cY1gmNO+hFaD zSgm;hdHqVh^ znbC>M?S^V0EUQDXm2L45hJ~@rX|p}E@pji(1B{>x*;v|DZaK1#j*H>^-Zw1m*3Y(! z`mrp^#l7CKF5TQayo0Lmt6wj^tp2D@t9RAU)oDv?Nl#1erniEsqa_?Pm2y)2@eFyK z_C|8VWZo-EJw$U}a5_wYU(t0Gr^iVSd0d{qE>#>)_O)BBAw+2V%m$7~=z7Qrya)lI z9`cBAUEdD@BwnQ!Qb#=0@ByF;_wt@Yg5ft-|Dsbs(u zTDK-uXO84L#|`TAH96{{+yL_~urw*I^V?ZP@9g#E)(r~Q_0a1jYK;Kx+SUI@Np}^7)yGeEwq%-AM6yifbHqCfOgHzo~c17h`n}&)-bqqgzlb_f!~SelzEt z$^2R%Oiv<|TE>3_Ox^b8iCyiqGhtD~rqino$}&#%{RRabK~i>A&PvCfNv`Tub$ao2 zbyoeBS3O=6mYr?ZvZRxBOo`Go--{rr4f_=wI=X{r4~5{`K4M z?_Zw2|L&Xjuih>B=3eyJ-Y0mgHC*fo0hA-|1_DtBd=xSvk&HZs2?Wfirq+l{Q)oD0 z%lkw5~z0 zz6^*@P~-#-<)Ifu%+~`TKhWx1vU+(7fEV|O!_4b)#0af=-{`8>VqL-0S`$XE@CKwwFMbi~O-v0n(2EkqT^gb1(N;v(xua{sGqmAq{pH004$u BmK6X1 literal 0 HcmV?d00001 diff --git a/test/fixtures/89450a383b06d3be5d7cf6f7c7234721.headers b/test/fixtures/89450a383b06d3be5d7cf6f7c7234721.headers new file mode 100644 index 0000000..9f23fbc --- /dev/null +++ b/test/fixtures/89450a383b06d3be5d7cf6f7c7234721.headers @@ -0,0 +1,29 @@ +{ + "statusCode": 200, + "headers": { + "date": "Sat, 04 Nov 2017 22:18:55 GMT", + "content-type": "application/json; charset=UTF-8", + "transfer-encoding": "chunked", + "connection": "keep-alive", + "keep-alive": "timeout=15", + "vary": "Accept-Encoding", + "x-ratelimit-limit": "1200", + "x-ratelimit-remaining": "635", + "x-ratelimit-reset": "1509833935", + "last-modified": "Sat, 04 Nov 2017 21:24:29 GMT", + "server": "Jetty(9.3.10.v20160621)", + "access-control-allow-origin": "*", + "content-encoding": "gzip" + }, + "url": "http://musicbrainz.org:80/ws/2/area?limit=5&query=Germany&fmt=json", + "time": 552, + "request": { + "method": "GET", + "headers": { + "User-Agent": "graphbrainz/7.0.0 ( 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/d191cb9a3134c90cfaa98b8b73f9e8c9 b/test/fixtures/d191cb9a3134c90cfaa98b8b73f9e8c9 new file mode 100644 index 0000000..74bc844 --- /dev/null +++ b/test/fixtures/d191cb9a3134c90cfaa98b8b73f9e8c9 @@ -0,0 +1 @@ +{"iso-3166-1-codes":["DE"],"id":"85752fda-13c4-31a3-bee5-0e5cb1f51dad","name":"Germany","sort-name":"Germany","disambiguation":"","type":"Country","type-id":"06dd0ae4-8c74-30bb-b43d-95dcedf961de","life-span":{"begin":null,"ended":false,"end":null}} \ No newline at end of file diff --git a/test/fixtures/d191cb9a3134c90cfaa98b8b73f9e8c9.headers b/test/fixtures/d191cb9a3134c90cfaa98b8b73f9e8c9.headers new file mode 100644 index 0000000..360774a --- /dev/null +++ b/test/fixtures/d191cb9a3134c90cfaa98b8b73f9e8c9.headers @@ -0,0 +1,27 @@ +{ + "statusCode": 200, + "headers": { + "date": "Sat, 04 Nov 2017 22:18:56 GMT", + "content-type": "application/json; charset=utf-8", + "content-length": "248", + "connection": "keep-alive", + "keep-alive": "timeout=15", + "x-ratelimit-limit": "1200", + "x-ratelimit-remaining": "1048", + "x-ratelimit-reset": "1509833937", + "server": "Plack::Handler::Starlet", + "etag": "\"82c22921587af20efc7bb9480993b28f\"", + "access-control-allow-origin": "*" + }, + "url": "http://musicbrainz.org:80/ws/2/area/85752fda-13c4-31a3-bee5-0e5cb1f51dad?fmt=json", + "time": 370, + "request": { + "method": "GET", + "headers": { + "User-Agent": "graphbrainz/7.0.0 ( 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 d735ed9..fa56082 100644 --- a/test/schema.js +++ b/test/schema.js @@ -502,6 +502,22 @@ test('area maps iso-3166-1-codes to isoCodes', testData, ` t.deepEqual(data.lookup.area.isoCodes, ['US']) }) +test('areas have a type and typeID', testData, ` + { + search { + areas(query: "Germany", first: 5) { + nodes { + name + type + typeID + } + } + } + } +`, (t, data) => { + t.snapshot(data) +}) + test('alias locales use the locale scalar', testData, ` { lookup { diff --git a/test/snapshots/schema.js.md b/test/snapshots/schema.js.md new file mode 100644 index 0000000..076020f --- /dev/null +++ b/test/snapshots/schema.js.md @@ -0,0 +1,43 @@ +# Snapshot report for `test/schema.js` + +The actual snapshot is saved in `schema.js.snap`. + +Generated by [AVA](https://ava.li). + +## areas have a type and typeID + +> Snapshot 1 + + { + search: { + areas: { + nodes: [ + { + name: 'Germany', + type: 'Country', + typeID: '06dd0ae4-8c74-30bb-b43d-95dcedf961de', + }, + { + name: 'East Germany', + type: 'Country', + typeID: '06dd0ae4-8c74-30bb-b43d-95dcedf961de', + }, + { + name: 'New Germany', + type: 'City', + typeID: '6fd8f29a-3d0a-32fc-980d-ea697b69da78', + }, + { + name: 'New Germany', + type: 'City', + typeID: '6fd8f29a-3d0a-32fc-980d-ea697b69da78', + }, + { + name: 'Brakel', + type: 'City', + typeID: '6fd8f29a-3d0a-32fc-980d-ea697b69da78', + }, + ], + }, + }, + } diff --git a/test/snapshots/schema.js.snap b/test/snapshots/schema.js.snap new file mode 100644 index 0000000000000000000000000000000000000000..3d34741dc331043a5ea4e1cc8598afe46c3bf757 GIT binary patch literal 491 zcmVLYRp6?6WVl>g+7B&a3Sa` zxUMejs*j*hy6M^%P`|k}t=vZJO63>?MLK{iAG3Sk_br)by0O&O(#ziFXRVAnmsQ9uNIf>;*%*E}PxFw{Du_tKQNy1BlM|e$G#$U14T$1pv zawwM1=T+!1panRBxUQ}$V>`sMlZYN?lqvc%qlTi-7*R7j(_AIGPUsLmGi?OxuMx;` zPO2Y-oB{C4&>Z$4M?$KPgag8@S=ZnKXIa)ir5%`;TU!)rr$Y*Vvin&0>G~!t;gjxGcNXs8V)IUKqMz zxg^|RRzy*jnY*