2016-09-01 08:39:27 +00:00
|
|
|
import { GraphQLObjectType, GraphQLNonNull, GraphQLString } from 'graphql'
|
|
|
|
|
import { forwardConnectionArgs } from 'graphql-relay'
|
|
|
|
|
import { searchResolver } from '../resolvers'
|
2016-08-20 05:59:32 +00:00
|
|
|
import {
|
2016-09-01 04:31:48 +00:00
|
|
|
AreaConnection,
|
|
|
|
|
ArtistConnection,
|
|
|
|
|
LabelConnection,
|
|
|
|
|
PlaceConnection,
|
|
|
|
|
RecordingConnection,
|
|
|
|
|
ReleaseConnection,
|
|
|
|
|
ReleaseGroupConnection,
|
|
|
|
|
WorkConnection
|
2016-08-20 05:59:32 +00:00
|
|
|
} from '../types'
|
2016-09-01 08:39:27 +00:00
|
|
|
|
|
|
|
|
function searchQuery (connectionType) {
|
|
|
|
|
return {
|
|
|
|
|
type: connectionType,
|
|
|
|
|
args: {
|
|
|
|
|
query: { type: new GraphQLNonNull(GraphQLString) },
|
|
|
|
|
...forwardConnectionArgs
|
|
|
|
|
},
|
|
|
|
|
resolve: searchResolver()
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-20 05:59:32 +00:00
|
|
|
|
|
|
|
|
export default new GraphQLObjectType({
|
|
|
|
|
name: 'SearchQuery',
|
|
|
|
|
description:
|
|
|
|
|
'Search queries provide a way to search for MusicBrainz entities using ' +
|
|
|
|
|
'Lucene query syntax.',
|
|
|
|
|
fields: {
|
2016-09-01 04:31:48 +00:00
|
|
|
areas: searchQuery(AreaConnection),
|
|
|
|
|
artists: searchQuery(ArtistConnection),
|
|
|
|
|
labels: searchQuery(LabelConnection),
|
|
|
|
|
places: searchQuery(PlaceConnection),
|
|
|
|
|
recordings: searchQuery(RecordingConnection),
|
|
|
|
|
releases: searchQuery(ReleaseConnection),
|
|
|
|
|
releaseGroups: searchQuery(ReleaseGroupConnection),
|
|
|
|
|
works: searchQuery(WorkConnection)
|
2016-08-20 05:59:32 +00:00
|
|
|
}
|
|
|
|
|
})
|