Vulcan/packages/example-interfaces/lib/modules/interfaces.js
ochicf 2c6526f81f Added example-interfaces package
Shows how to use a simple a hierarchical interface implemented in a Categories collection.
2017-07-22 11:37:06 +02:00

18 lines
543 B
JavaScript

import { addGraphQLSchema, addGraphQLResolvers } from 'meteor/vulcan:core';
addGraphQLSchema(`
interface HierarchicalInterface {
parentId: String
parent: HierarchicalInterface
}
`);
// type must be resolved dynamically at execution time. To prevent this resolver from knowing
// all the implementing types we return the parentType name. Note that this may not always work
const resolveType = (obj, context, info) => info.parentType.name;
addGraphQLResolvers({
HierarchicalInterface: {
__resolveType: resolveType,
},
});