import { CmsModel , CmsContext , CmsFieldTypePlugins } from "~/types" ; import { GraphQLSchemaDefinition } from "@webiny/handler-graphql/types" ; interface RenderTypesFromFieldPlugins { ( params ) : GraphQLSchemaDefinition < CmsContext > [ ] ; } const TYPE_MAP = { preview : "read" , read : "read" , manage : "manage" } ; export const getSchemaFromFieldPlugins = ( { models , fieldTypePlugins , type } ) => { return Object . values ( fieldTypePlugins ) . map ( pl => { if ( typeof pl [ TYPE_MAP [ type ] ] . createSchema === "function" ) { return pl [ TYPE_MAP [ type ] ] . createSchema ( { models } ) ; } return null ; } ) . filter ( Boolean ) ; } ;