UNPKG

polen

Version:

A framework for delightful GraphQL developer portals

40 lines 1.35 kB
import { neverCase } from '@wollybeard/kit/language'; import { locateTargetField, locateTargetType } from '../target.js'; export const Placement = { Before: `before`, After: `after`, Over: `over`, }; export const applyDescriptionContent = (type, augmentation) => { const existingDescription = type.description ?? ``; switch (augmentation.placement) { case `before`: type.description = `${augmentation.content}\n\n${existingDescription}`; break; case `after`: type.description = `${existingDescription}\n\n${augmentation.content}`; break; case `over`: type.description = augmentation.content; break; default: neverCase(augmentation.placement); } }; export const apply = (schema, augmentation) => { switch (augmentation.on.type) { case `TargetType`: { const type = locateTargetType(schema, augmentation.on); applyDescriptionContent(type, augmentation); break; } case `TargetField`: { const field = locateTargetField(schema, augmentation.on); applyDescriptionContent(field, augmentation); break; } default: neverCase(augmentation.on); } }; //# sourceMappingURL=description.js.map