How to use the graphile-build-pg.inflections.newInflector 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 / postgraphile-core / src / index.ts View on Github external
},
};

export const postGraphileClassicIdsOverrides = {
  column(name: string, _table: string, _schema?: string) {
    return name === "id" ? "rowId" : inflections.defaultUtils.camelCase(name);
  },
};

export const postGraphileInflection = inflections.newInflector(
  // @ts-ignore
  postGraphileBaseOverrides
);

// @ts-ignore
export const postGraphileClassicIdsInflection = inflections.newInflector({
  ...postGraphileBaseOverrides,
  ...postGraphileClassicIdsOverrides,
});
/*
 * ABOVE HERE IS DEPRECATED.
 */

export const PostGraphileInflectionPlugin = function(builder: SchemaBuilder) {
  builder.hook("inflection", (inflection: Inflection) => {
    const previous = inflection.enumName;
    // Overwrite directly so that we don't lose the 'extend' hints
    Object.assign(inflection, {
      enumName(value: string) {
        return this.constantCase(previous.call(this, value));
      },
    });
github graphile / graphile-engine / packages / postgraphile-core / src / index.ts View on Github external
export const postGraphileBaseOverrides = {
  enumName(value: string) {
    return inflections.defaultUtils.constantCase(
      inflections.defaultInflection.enumName(value)
    );
  },
};

export const postGraphileClassicIdsOverrides = {
  column(name: string, _table: string, _schema?: string) {
    return name === "id" ? "rowId" : inflections.defaultUtils.camelCase(name);
  },
};

export const postGraphileInflection = inflections.newInflector(
  // @ts-ignore
  postGraphileBaseOverrides
);

// @ts-ignore
export const postGraphileClassicIdsInflection = inflections.newInflector({
  ...postGraphileBaseOverrides,
  ...postGraphileClassicIdsOverrides,
});
/*
 * ABOVE HERE IS DEPRECATED.
 */

export const PostGraphileInflectionPlugin = function(builder: SchemaBuilder) {
  builder.hook("inflection", (inflection: Inflection) => {
    const previous = inflection.enumName;

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