How to use the webiny-entity.EntityPool function in webiny-entity

To help you get started, we’ve selected a few webiny-entity examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webiny / webiny-js / packages / webiny-api / src / plugins / graphqlContextEntities.js View on Github external
getPlugins("entity").forEach((plugin: EntityPluginType) => {
            if (!context[plugin.namespace]) {
                context[plugin.namespace] = {
                    entities: {}
                };
            }

            if (typeof plugin.entity === "function") {
                const entityClass = plugin.entity(context);
                entityClass.pool = new EntityPool();
                registerEntityClass({ context, entityClass });
            } else {
                const { name, factory } = plugin.entity;
                context[plugin.namespace].entities[name] = factory(context);
                context[plugin.namespace].entities[name].pool = new EntityPool();

                // We add to entities list, later we'll just do the cleanup - this won't exist.
                registerEntityClass({
                    context,
                    entityClass: context[plugin.namespace].entities[name]
                });
            }
        });
    }