1234567891011121314151617181920212223242526272829303132 |
- 'use strict';
- const {
- nodeDefinitions,
- fromGlobalId
- } = require('graphql-relay');
- // At this point, videoType is not yet defined because of the require loop.
- const { getObjectById } = require('./data');
- const { nodeInterface, nodeField } = nodeDefinitions(
- // Load an object from its id.
- globalId => {
- const { type, id } = fromGlobalId(globalId);
- return getObjectById(type.toLowerCase(), id);
- },
- // Returns the object type.
- object => {
- // But this import is done after the whole loading require loop has completed.
- const { videoType } = require('../index');
- if (object.title) {
- return videoType;
- }
- return null;
- }
- );
- exports.nodeInterface = nodeInterface;
- exports.nodeField = nodeField;
|