graphbrainz
Version:
A GraphQL schema, Express server, and middleware for querying the MusicBrainz.
18 lines (14 loc) • 501 B
JavaScript
import GraphQLRelay from 'graphql-relay';
import { toDashed } from '../util.js';
import { resolveType } from './helpers.js';
const { nodeDefinitions, fromGlobalId } = GraphQLRelay;
const { nodeInterface, nodeField } = nodeDefinitions(
(globalID, { loaders }) => {
const { type, id } = fromGlobalId(globalID);
const entityType = toDashed(type);
return loaders.lookup.load([entityType, id]);
},
resolveType
);
export const Node = nodeInterface;
export { nodeInterface, nodeField };