UNPKG

graphql-modules

Version:

Create reusable, maintainable, testable and extendable GraphQL modules

18 lines (17 loc) 483 B
import { noInjectableError } from './errors'; export const INJECTABLE = Symbol('di:injectable'); export function readInjectableMetadata(type, throwOnMissing) { const meta = type[INJECTABLE]; if (!meta && throwOnMissing) { throw noInjectableError(type); } return meta; } export function ensureInjectableMetadata(type) { if (!readInjectableMetadata(type)) { const meta = { params: [], }; type[INJECTABLE] = meta; } }