mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 04:26:41 -04:00

Shows how to use a simple a hierarchical interface implemented in a Categories collection.
18 lines
543 B
JavaScript
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,
|
|
},
|
|
});
|