UNPKG

graphql-modules

Version:

Create reusable, maintainable, testable and extendable GraphQL modules

23 lines (22 loc) 604 B
import { stringify } from './utils'; const forwardRefSymbol = Symbol('__forward_ref__'); /** * Useful in "circular dependencies of modules" situation */ export function forwardRef(forwardRefFn) { forwardRefFn[forwardRefSymbol] = forwardRef; forwardRefFn.toString = function () { return stringify(this()); }; return forwardRefFn; } export function resolveForwardRef(type) { if (typeof type === 'function' && type.hasOwnProperty(forwardRefSymbol) && type[forwardRefSymbol] === forwardRef) { return type(); } else { return type; } }