graphbrainz/src/types/node.js

18 lines
501 B
JavaScript
Raw Normal View History

import GraphQLRelay from 'graphql-relay';
import { toDashed } from '../util.js';
import { resolveType } from './helpers.js';
2016-08-31 06:33:29 +00:00
const { nodeDefinitions, fromGlobalId } = GraphQLRelay;
2016-08-31 06:33:29 +00:00
const { nodeInterface, nodeField } = nodeDefinitions(
2016-11-26 01:38:32 +00:00
(globalID, { loaders }) => {
const { type, id } = fromGlobalId(globalID);
const entityType = toDashed(type);
return loaders.lookup.load([entityType, id]);
2016-08-31 06:33:29 +00:00
},
resolveType
);
2016-08-31 06:33:29 +00:00
export const Node = nodeInterface;
export { nodeInterface, nodeField };