How to use the graphile-build-pg.PgEntityKind.ATTRIBUTE function in graphile-build-pg

To help you get started, we’ve selected a few graphile-build-pg 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 graphile / graphile-engine / packages / graphile-utils / src / makePgSmartTagsPlugin.ts View on Github external
);
      }

      rules.push({
        kind,
        match: identifier,
        tags,
        description,
      });

      if (columns) {
        // This was in graphile-utils 4.0.0 but was deprecated in 4.0.1 for consistency reasons.
        process(
          kind,
          identifier,
          PgEntityKind.ATTRIBUTE,
          columns,
          "columns",
          true
        );
      }
      if (attribute) {
        process(
          kind,
          identifier,
          PgEntityKind.ATTRIBUTE,
          attribute,
          "attribute"
        );
      }
      if (constraint) {
        process(
github graphile / graphile-engine / packages / graphile-utils / src / makePgSmartTagsPlugin.ts View on Github external
tags?: PgSmartTagTags;
  description?: string;
}

export type PgSmartTagSupportedKinds =
  | PgEntityKind.CLASS
  | PgEntityKind.ATTRIBUTE
  | PgEntityKind.CONSTRAINT
  | PgEntityKind.PROCEDURE;

const meaningByKind: {
  [kind in PgSmartTagSupportedKinds]: string;
} = {
  [PgEntityKind.CLASS]:
    "for tables, composite types, views and materialized views",
  [PgEntityKind.ATTRIBUTE]: "for columns/attributes (of any 'class' type)",
  [PgEntityKind.CONSTRAINT]: "for table constraints",
  [PgEntityKind.PROCEDURE]: "for functions/procedures",
};

const validKinds = Object.entries(meaningByKind)
  .map(([kind, meaning]) => `'${kind}' (${meaning})`)
  .join(", ");

function compileRule(
  rule: PgSmartTagRule
): CompiledPgSmartTagRule {
  const { kind, match: incomingMatch, ...rest } = rule;
  if (!Object.prototype.hasOwnProperty.call(meaningByKind, kind)) {
    throw new Error(
      `makePgSmartTagsPlugin rule has invalid kind '${kind}'; valid kinds are: ${validKinds}`
    );
github graphile / graphile-engine / packages / graphile-utils / src / introspectionHelpers.ts View on Github external
export function isAttribute(obj: PgEntity): obj is PgAttribute {
  return obj.kind === PgEntityKind.ATTRIBUTE;
}

graphile-build-pg

Build a GraphQL schema by reflection over a PostgreSQL schema. Easy to customize since it's built with plugins on graphile-build

MIT
Latest version published 2 years ago

Package Health Score

66 / 100
Full package analysis