keystone-field-nested-set
v4.0.1-2
Published
nested set field for keystonejs
Downloads
9
Readme
Nested Set Keystone field type
Add nested set field for Keystone headless CNS. It allows you to create and manipulate with tree-like structures with child and parent items.
Nested Set model
The Nested Set model is described here: https://en.wikipedia.org/wiki/Nested_set_model
This module stores nested set data in the database using field names:
left
, rigth
, depth
Graphql Scheme
Output
left
: Intright
: Intdepth
: Intweight
: Int // Serial number through current branchparentId
: ID// Keystone id of direct parent elementisLeaf
: Boolean, true if have no childrenchildrenCount
// counts children
Filters
parentId
: type ID // Keystone id of direct parent elementchildOf
// filters all elements that are children of that Keystone idparentOf
// filters all elements that are parent of that Keystone idprevSiblingOf
: ID! // left sibling element, null if absentnextSiblingOf
: ID! // right sibling element, null if absent
Mutation
Create and Update
parentId
: ID // Keystone id of direct parent elementprevSiblingId
: ID // Keystone id of left sibling elementnextSiblingId
: ID // Keystone id of right sibling element
Delete
If node has children they move to the parent of deleted node.
Recompiling
The module requires to be compiled with the same major versions of the NPM modules:
keystone-6/core
@keystone-ui/core
@keystone-ui/fields
graphql
So, if you get problems on launching Keystone with this module, getting these errors:
- Schema must contain uniquely named types but contains multiple types named "OrderDirection".
- Duplicate "graphql" modules cannot be used at the same time
You need to change dependencies to the exact ones, that is uses in your application and in the keystone-6/core
package.
Recompiling procedure in case you have the Keystone Core from sources in your project.
- Create a link to the sources of both projects - execute this command on each directory:
yarn link
- In your project directory: cleanup the
node_modules
folder, link the Nested Set module, and preconstruct:
rm -rf ./node-modules && yarn link && yarn link keystone-field-nested-set && yarn preconstruct && yarn install
- In
keystone-nested-set
directory: build with linked Keystone sources:
rm -rf ./node-modules && yarn link @keystone-6/core && yarn && yarn build
- On your project directory: build with recently rebuilt Nested Set module:
yarn build