graphbrainz/src/queries/browse.js

79 lines
1.9 KiB
JavaScript
Raw Normal View History

2016-09-01 08:39:27 +00:00
import { GraphQLObjectType } from 'graphql'
import { forwardConnectionArgs } from 'graphql-relay'
import { browseResolver } from '../resolvers'
2016-08-20 05:59:32 +00:00
import {
MBID,
URLString,
2016-09-01 04:31:48 +00:00
ArtistConnection,
EventConnection,
LabelConnection,
PlaceConnection,
RecordingConnection,
ReleaseConnection,
ReleaseGroupConnection,
URLConnection,
WorkConnection
2016-08-20 05:59:32 +00:00
} from '../types'
2016-09-01 08:39:27 +00:00
function browseQuery (connectionType, args) {
return {
type: connectionType,
args: {
...forwardConnectionArgs,
...args
},
resolve: browseResolver()
}
}
2016-08-20 05:59:32 +00:00
export default new GraphQLObjectType({
name: 'BrowseQuery',
description:
'Browse requests are a direct lookup of all the entities directly linked ' +
'to another entity.',
fields: {
2016-09-01 08:39:27 +00:00
artists: browseQuery(ArtistConnection, {
area: { type: MBID },
recording: { type: MBID },
release: { type: MBID },
releaseGroup: { type: MBID },
work: { type: MBID }
}),
events: browseQuery(EventConnection, {
area: { type: MBID },
artist: { type: MBID },
place: { type: MBID }
}),
labels: browseQuery(LabelConnection, {
area: { type: MBID },
release: { type: MBID }
}),
places: browseQuery(PlaceConnection, {
area: { type: MBID }
}),
recordings: browseQuery(RecordingConnection, {
artist: { type: MBID },
release: { type: MBID }
}),
releases: browseQuery(ReleaseConnection, {
area: { type: MBID },
artist: { type: MBID },
label: { type: MBID },
track: { type: MBID },
trackArtist: { type: MBID },
recording: { type: MBID },
releaseGroup: { type: MBID }
}),
releaseGroups: browseQuery(ReleaseGroupConnection, {
artist: { type: MBID },
release: { type: MBID }
}),
works: browseQuery(WorkConnection, {
artist: { type: MBID }
}),
urls: browseQuery(URLConnection, {
resource: { type: URLString }
})
2016-08-20 05:59:32 +00:00
}
})