How to use the @keystonejs/fields.Relationship.implementation function in @keystonejs/fields

To help you get started, we’ve selected a few @keystonejs/fields 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 keystonejs / keystone / packages / field-content / src / Implementation.js View on Github external
defaultVisitor(node, visitNode) {
        if (node.nodes) {
          // Recurse into the child nodes array
          node.nodes = node.nodes.map(childNode => visitNode(childNode));
        }

        return node;
      },
    }),
  };

  return result;
}

export class Content extends Relationship.implementation {
  constructor(path, { blocks: inputBlocks, ...fieldConfig }, listConfig) {
    // To maintain consistency with other types, we grab the sanitised name
    // directly from the list.
    const { itemQueryName } = listConfig.getListByKey(listConfig.listKey).gqlNames;

    // We prefix with `_` here to avoid any possible conflict with a list called
    // `ContentType`.
    // Including the list name + path to make sure these input types are unique
    // to this list+field and don't collide.
    const type = `${GQL_TYPE_PREFIX}_${itemQueryName}_${path}`;

    // Normalise blocks to always be a tuple with a config object
    let blocks = (Array.isArray(inputBlocks) ? inputBlocks : []).map(block =>
      Array.isArray(block) ? block : [block, {}]
    );

@keystonejs/fields

KeystoneJS Field Types including Text, Password, DateTime, Integer, and more.

MIT
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis

Similar packages