UNPKG

@redocly/graphql-docs

Version:

Redocly GraphQL docs

2 lines (1 loc) 701 B
import{TypeGroup as n}from"../../../schema/index.js";import{DEFAULT_MENU_GROUP_ID as u}from"../../models/index.js";import{getItemDoesNotMatchAnyGroupErrorMessage as i}from"./errors.js";import{insertIntoGroup as s}from"./insert-into-group.js";import{directiveMatchesGroup as c}from"./item-matches-group.js";import{shouldIncludeItem as a}from"./builtin-items.js";function l(o,t,r,e){t.getDirectives().forEach(m=>{if(!a({name:m.name},n.directives,e))return;f(m,r).forEach(p=>{s(o,m.name,p,n.directives,r)})})}function f(o,t){const r=t.groups.filter(e=>c(o,e)).map(e=>e.name);if(t.requireExactGroups&&!r.length)throw new Error(i(`Directive ${o.name}`));return r.length?r:[u]}export{l as groupDirectives};