UNPKG

@redocly/graphql-docs

Version:

Redocly GraphQL docs

2 lines (1 loc) 1.37 kB
import{isString as n}from"../../utils/is-string.js";function y(t,i){i?.groups?.forEach(e=>{s(e.name),o(t,e),a(t,e),c(t,e),u(t,e),d(t,e),f(t,e)})}function s(t){if(t.includes("/"))throw new Error(`Group name ${t} is invalid. "/" is not allowed in group names.`)}function o(t,i){i.items&&r(i.items).forEach(e=>{if(!t.getQueryType()?.getFields()[e]&&!t.getMutationType()?.getFields()[e]&&!t.getSubscriptionType()?.getFields()[e]&&!t.getDirective(e)&&!t.getType(e))throw new Error(`Item ${e} does not exist in schema.`)})}function a(t,i){i.queries&&r(i.queries).forEach(e=>{if(!t.getQueryType()?.getFields()[e])throw new Error(`Query ${e} does not exist in schema.`)})}function c(t,i){i.mutations&&r(i.mutations).forEach(e=>{if(!t.getMutationType()?.getFields()[e])throw new Error(`Mutation ${e} does not exist in schema.`)})}function u(t,i){i.subscriptions&&r(i.subscriptions).forEach(e=>{if(!t.getSubscriptionType()?.getFields()[e])throw new Error(`Subscription ${e} does not exist in schema.`)})}function d(t,i){i.directives&&r(i.directives).forEach(e=>{if(!t.getDirective(e))throw new Error(`Directive ${e} does not exist in schema.`)})}function f(t,i){i.types&&r(i.types).forEach(e=>{if(!t.getType(e))throw new Error(`Type ${e} does not exist in schema.`)})}function r(t){return t.includeByName?.concat(t.excludeByName||[]).filter(n)||[]}export{y as validateMenuConfig};