Skip to content

Commit

Permalink
feat(inflection): add more fields/types to inflector (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed Jan 11, 2019
1 parent 6218c6a commit 77452de
Show file tree
Hide file tree
Showing 17 changed files with 9,571 additions and 383 deletions.
4 changes: 0 additions & 4 deletions packages/graphile-build-pg/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ import PgMutationUpdateDeletePlugin from "./plugins/PgMutationUpdateDeletePlugin
import PgMutationProceduresPlugin from "./plugins/PgMutationProceduresPlugin";
import PgMutationPayloadEdgePlugin from "./plugins/PgMutationPayloadEdgePlugin";

import * as inflections from "./inflections";

import parseIdentifier from "./parseIdentifier";
import omit from "./omit";
export { formatSQLForDebugging } from "./plugins/debugSql";
Expand Down Expand Up @@ -75,8 +73,6 @@ export const defaultPlugins = [
PgMutationPayloadEdgePlugin,
];

export { inflections };

export {
PgBasicsPlugin,
PgIntrospectionPlugin,
Expand Down
323 changes: 0 additions & 323 deletions packages/graphile-build-pg/src/inflections.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import type { Plugin } from "graphile-build";

export default (function PageInfoStartEndCursor(builder) {
builder.hook("GraphQLObjectType:fields", (fields, build, context) => {
const { extend, getTypeByName } = build;
const { extend, getTypeByName, inflection } = build;
const { Self, fieldWithHooks } = context;
if (Self.name !== "PageInfo") {
if (Self.name !== inflection.pageInfo()) {
return fields;
}
const Cursor = getTypeByName("Cursor");
Expand Down
9 changes: 9 additions & 0 deletions packages/graphile-build-pg/src/plugins/PgBasicsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ export default (function PgBasicsPlugin(
return build.extend(
inflection,
preventEmptyResult({
// Postgres type names
pgIntervalType: () => "Interval",
pgIntervalInputType: () => "IntervalInput",
pgPointType: () => "Point",
pgPointInputType: () => "PointInput",

// These helpers are passed GraphQL type names as strings
conditionType(typeName: string) {
return this.upperCamelCase(`${typeName}-condition`);
Expand Down Expand Up @@ -747,6 +753,9 @@ export default (function PgBasicsPlugin(
deleteNode(table: PgClass) {
return this.camelCase(`delete-${this._singularizedTableName(table)}`);
},
deletedNodeId(table: PgClass) {
return this.camelCase(`deleted-${this.singularize(table.name)}-id`);
},
updateNodeInputType(table: PgClass) {
return this.upperCamelCase(
`update-${this._singularizedTableName(table)}-input`
Expand Down

0 comments on commit 77452de

Please sign in to comment.