mirror of
https://github.com/BradNut/graphbrainz
synced 2025-09-08 17:40:32 +00:00
Move query fields to live alongside query types
This commit is contained in:
parent
e3f8c805a0
commit
5f0710e353
5 changed files with 40 additions and 24 deletions
|
|
@ -50,7 +50,7 @@ function browseQuery (connectionType, args) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new GraphQLObjectType({
|
export const BrowseQuery = new GraphQLObjectType({
|
||||||
name: 'BrowseQuery',
|
name: 'BrowseQuery',
|
||||||
description: `A query for all MusicBrainz entities directly linked to another
|
description: `A query for all MusicBrainz entities directly linked to another
|
||||||
entity.`,
|
entity.`,
|
||||||
|
|
@ -118,3 +118,13 @@ release, but is not included in the credits for the release itself.`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const browseField = {
|
||||||
|
type: BrowseQuery,
|
||||||
|
description: 'Browse all MusicBrainz entities directly linked to another entity.',
|
||||||
|
// We only have work to do once we know what entity types are being requested,
|
||||||
|
// so this can just resolve to an empty object.
|
||||||
|
resolve: () => ({})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default BrowseQuery
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
export { default as LookupQuery } from './lookup'
|
export { LookupQuery, lookupField } from './lookup'
|
||||||
export { default as BrowseQuery } from './browse'
|
export { BrowseQuery, browseField } from './browse'
|
||||||
export { default as SearchQuery } from './search'
|
export { SearchQuery, searchField } from './search'
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ function lookupQuery (entity) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new GraphQLObjectType({
|
export const LookupQuery = new GraphQLObjectType({
|
||||||
name: 'LookupQuery',
|
name: 'LookupQuery',
|
||||||
description: 'A lookup of an individual MusicBrainz entity by its MBID.',
|
description: 'A lookup of an individual MusicBrainz entity by its MBID.',
|
||||||
fields: {
|
fields: {
|
||||||
|
|
@ -44,3 +44,13 @@ export default new GraphQLObjectType({
|
||||||
work: lookupQuery(Work)
|
work: lookupQuery(Work)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const lookupField = {
|
||||||
|
type: LookupQuery,
|
||||||
|
description: 'Perform a lookup of a MusicBrainz entity by its MBID.',
|
||||||
|
// We only have work to do once we know what entity types are being requested,
|
||||||
|
// so this can just resolve to an empty object.
|
||||||
|
resolve: () => ({})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LookupQuery
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ function searchQuery (connectionType) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new GraphQLObjectType({
|
export const SearchQuery = new GraphQLObjectType({
|
||||||
name: 'SearchQuery',
|
name: 'SearchQuery',
|
||||||
description: 'A search for MusicBrainz entities using Lucene query syntax.',
|
description: 'A search for MusicBrainz entities using Lucene query syntax.',
|
||||||
fields: {
|
fields: {
|
||||||
|
|
@ -40,3 +40,13 @@ export default new GraphQLObjectType({
|
||||||
works: searchQuery(WorkConnection)
|
works: searchQuery(WorkConnection)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const searchField = {
|
||||||
|
type: SearchQuery,
|
||||||
|
description: 'Search for MusicBrainz entities using Lucene query syntax.',
|
||||||
|
// We only have work to do once we know what entity types are being requested,
|
||||||
|
// so this can just resolve to an empty object.
|
||||||
|
resolve: () => ({})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SearchQuery
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { GraphQLSchema, GraphQLObjectType } from 'graphql'
|
import { GraphQLSchema, GraphQLObjectType } from 'graphql'
|
||||||
import { LookupQuery, BrowseQuery, SearchQuery } from './queries'
|
import { lookupField, browseField, searchField } from './queries'
|
||||||
import { nodeField } from './types/node'
|
import { nodeField } from './types/node'
|
||||||
|
|
||||||
export default new GraphQLSchema({
|
export default new GraphQLSchema({
|
||||||
|
|
@ -9,23 +9,9 @@ export default new GraphQLSchema({
|
||||||
requests can be made.`,
|
requests can be made.`,
|
||||||
fields: () => ({
|
fields: () => ({
|
||||||
node: nodeField,
|
node: nodeField,
|
||||||
lookup: {
|
lookup: lookupField,
|
||||||
type: LookupQuery,
|
browse: browseField,
|
||||||
description: 'Perform a lookup of a MusicBrainz entity by its MBID.',
|
search: searchField
|
||||||
resolve: () => ({})
|
|
||||||
},
|
|
||||||
browse: {
|
|
||||||
type: BrowseQuery,
|
|
||||||
description: `Browse all MusicBrainz entities directly linked to another
|
|
||||||
entity.`,
|
|
||||||
resolve: () => ({})
|
|
||||||
},
|
|
||||||
search: {
|
|
||||||
type: SearchQuery,
|
|
||||||
description: `Search for MusicBrainz entities using Lucene query
|
|
||||||
syntax.`,
|
|
||||||
resolve: () => ({})
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue