github graphile/crystal @graphile/simplify-inflection@8.0.0

v8.0.0

8.0.0-rc.5

Patch Changes

  • #2990
    5d408bd
    Thanks @benjie! - No code changes. Updates the
    release process, cleans up package.json, uses fixed identifiers for peer
    dependencies (unless they're explicit dependencies also). Hopefully move to
    trusted publishing.

8.0.0-rc.4

Patch Changes

  • #2957
    5615d3f
    Thanks @benjie! - Significantly reduce the size
    of a PostGraphile exported schema (around 20% reduction on test fixtures) by:

    • marking optional things as optional
    • excluding many optional things from being specified in configuration objects
      (including tags objects if no tags are present)
    • using LIST_TYPES for PostgreSQL builtin list types
    • extracting inline function definitions to be global functions where
      appropriate, and simplifying functions where not

    Breaking changes to types (but more accurate reflection of reality):

    • extensions is now marked as optional in many places.
    • extensions.tags is now marked optional in many places.
    • PgCodecAttribute.notNull is now marked as optional.
    • PgResourceParameter.requires is now marked as optional.
    • PgCodecRelation.isUnique is now marked as optional.
    • pgGetArgDetailsFromParameters().argDetails.postgresArgName is now optional
      (may return undefined in addition to null) and .required is now
      optional (returns boolean | undefined)

8.0.0-rc.3

Patch Changes

8.0.0-rc.2

Patch Changes

8.0.0-rc.1

Patch Changes

8.0.0-beta.8

Patch Changes

  • #2682
    88146e2
    Thanks @benjie! - 🚨 Fix bug where names were
    incorrectly derived for AmberPreset/RelayPreset.

    If you need to restore the old (broken) behavior, use something this plugin
    (untested):

    const ShinyFlowersBeamUndoPlugin = {
      name: "ShinyFlowersBeamUndoPlugin",
      inflection: {
        replace: {
          _getBaseNameFromKeys(original, preset, detailedKeys) {
            if (detailedKeys.length === 1) {
              const key = detailedKeys[0];
              const attributeName = this._attributeName({
                ...key,
                skipRowId: false, // HACK: deliberately opt in to poor naming
              });
              return this._getBaseName(attributeName);
            }
            if (preset.schema?.pgSimplifyMultikeyRelations) {
              const attributeNames = detailedKeys.map((key) =>
                this._attributeName({
                  ...key,
                  skipRowId: true, // HACK: deliberately opt in to poor naming
                }),
              );
              const baseNames = attributeNames.map((attributeName) =>
                this._getBaseName(attributeName),
              );
              // Check none are null
              if (baseNames.every((n) => n)) {
                return baseNames.join("-");
              }
            }
            return null;
          },
        },
      },
    };

8.0.0-beta.7

Patch Changes

8.0.0-beta.6

Patch Changes

8.0.0-beta.5

Patch Changes

8.0.0-beta.4

Patch Changes

8.0.0-beta.3

Patch Changes

8.0.0-beta.2

Patch Changes

8.0.0-beta.1

Patch Changes

8.0.0-alpha.4

Patch Changes

  • #408
    01ad64d5d
    Thanks @benjie! - Renamed getBaseName,
    baseNameMatches, getOppositeBaseName and getBaseNameFromKeys inflectors
    to all begin with an underscore (_) - this is because these inflectors
    should only be used from other inflectors, since they may return non-string
    types (null/boolean/etc).

8.0.0-alpha.3

Patch Changes

8.0.0-alpha.2

Patch Changes

  • f61879689
    Thanks @benjie! - Fix baseNameMatches to resolve
    a regression in simplify-inflector V7 compatibility.

  • 7f857950a
    Thanks @benjie! - Upgrade to the latest
    TypeScript/tslib

8.0.0-alpha.1

Patch Changes

8.0.0-1.1

Patch Changes

  • #260
    d5312e6b9
    Thanks @benjie! - TypeScript v5 is now required

  • #260
    96b0bd14e
    Thanks @benjie! - PgSource has been renamed to
    PgResource, PgTypeCodec to PgCodec, PgEnumTypeCodec to PgEnumCodec,
    PgTypeColumn to PgCodecAttribute (and similar for related
    types/interfaces). source has been replaced by resource in various of the
    APIs where it relates to a PgResource.

    PgSourceBuilder is no more, instead being replaced with PgResourceOptions
    and being built into the final PgResource via the new
    makeRegistryBuilder/makeRegistry functions.

    build.input no longer contains the pgSources directly, instead
    build.input.pgRegistry.pgResources should be used.

    The new registry system also means that various of the hooks in the gather
    phase have been renamed/replaced, there's a new PgRegistryPlugin plugin in
    the default preset. The only plugin that uses the main method in the
    gather phase is now PgRegistryPlugin - if you are using the main
    function for Postgres-related behaviors you should consider moving your logic
    to hooks instead.

    Plugin ordering has changed and thus the shape of the final schema is likely
    to change (please use lexicographicSortSchema on your before/after schemas
    when comparing).

    Relationships are now from a codec to a resource, rather than from resource to
    resource, so all the relationship inflectors (singleRelation,
    singleRelationBackwards, _manyRelation, manyRelationConnection,
    manyRelationList) now accept different parameters
    ({registry, codec, relationName} instead of {source, relationaName}).

    Significant type overhaul, most generic types no longer require generics to be
    explicitly passed in many circumstances. PgSelectStep, PgSelectSingleStep,
    PgInsertStep, PgUpdateStep and PgDeleteStep now all accept the resource
    as their single type parameter rather than accepting the 4 generics they did
    previously. PgClassExpressionStep now accepts just a codec and a resource as
    generics. PgResource and PgCodec have gained a new TName extends string
    generic at the very front that is used by the registry system to massively
    improve continuity of the types through all the various APIs.

    Fixed various issues in schema exporting, and detect more potential
    issues/oversights automatically.

    Fixes an RBAC bug when using superuser role for introspection.

  • #271
    261eb520b
    Thanks @benjie! - 🚨 RENAME ALL THE THINGS

    The term 'source' was overloaded, and 'configs' was too vague, and
    'databaseName' was misleading, and 'source' behaviours actually applied to
    resources, and more. So, we've renamed lots of things as part of the API
    stabilization work. You're probably only affected by the first 2 bullet
    points.

    • pgConfigs -> pgServices (also applies to related pgConfig terms such
      as makePgConfig -> makePgService, MakePgConfigOptions ->
      MakePgServiceOptions, etc) - see your graphile.config.ts or equivalent
      file
    • All *:source:* behaviors are now *:resource:* behaviors (use regexp
      /:source\b|\bsource:[a-z$]/ to find the places that need updating)
    • PgDatabaseConfiguration -> PgServiceConfiguration
    • databaseName -> serviceName (because it's not the name of the database,
      it's the name of the pgServices (which was pgConfigs) entry)
    • PgResourceConfig::source -> PgResourceConfig.from ('source' is
      overloaded, so use a more direct term)
    • PgResource::source -> PgResource.from
    • PgSelectPlanJoin::source -> PgSelectPlanJoin.from
    • helpers.pgIntrospection.getDatabase ->
      helpers.pgIntrospection.getService
    • helpers.pgIntrospection.getExecutorForDatabase ->
      helpers.pgIntrospection.getExecutorForService

8.0.0-0.5

Patch Changes

  • a8d26b30a - ignoreReplaceIfNotExists now truly ignores
    replacement inflectors. Better handle disabled NodePlugin.

8.0.0-0.4

Patch Changes

  • #211
    f9c523bb6
    Thanks @benjie! - Simplified relations should
    still respect foreignFieldName if present

8.0.0-0.3

Patch Changes

  • 0ab95d0b1 - Update sponsors.

8.0.0-0.2

Patch Changes

  • #177
    6be68a53e
    Thanks @benjie! - @foreignFieldName smart tag
    is now fed into the inflection.connectionField(...) or
    inflection.listField(...) inflector as appropriate. If you are using
    @foreignSimpleFieldName you may be able to delete that now; alternatively
    you should consider renaming @foreignFieldName to
    @foreignConnectionFieldName for consistency.

  • #176
    11d6be65e
    Thanks @benjie! - Fix issue with plugin
    versioning. Add more TSDoc comments. New getTerminalWidth() helper.

8.0.0-0.1

Patch Changes

  • 867121cfb - V5 port of @graphile-contrib/pg-simplify-inflector

This is based on V7 of @graphile-contrib/pg-simplify-inflector, rewritten for
PostGraphile V5. The previous versions relate to
@graphile-contrib/pg-simplify-inflector instead.

v7.0.0

Simplify primary key to primary key references

If you have two tables that share a primary key value, this version will
simplify the reference. For example with the following database schema:

create table animals (
  id serial primary key,
  name text
);

create table dogs (
  animal_id int primary key references animals,
  wags_tail bool
);

This will create Animal.dog (rather than Animal.dogById) and Dog.animal
(rather than Dog.animalById).

v6.1.0

Add @listSuffix smart tag

Previously there was no easy way to override pgOmitListSuffix on a per-entity
basis. With the @listSuffix tag you can selectively control naming of both
collection types:

create table companies (id serial primary key);
comment on table companies is E'@listSuffix omit';

By default (pgOmitListSuffix = null and simpleCollections = 'both') this
produces:

-  allCompanies(
+  companiesConnection(
-  allCompaniesList(
+  companies(

v6.0.0

Pluralization fixes

Previously we fed the entire table/etc name into pluralize but this causes
issues for special cases, for example while pluralize('genus') correctly gives
genera, pluralize('old_genus') would give old_genus which is not correct.

Now we segment on underscores/capitals and only pluralize the final segment, so
we're more likely to get the correct result.

This affects everywhere in your entire GraphQL schema where
pluralize/singularize is used.

Simplify multi-key relationships.

  foreign key (organization_id, team_id, goal_uuid) references goals

Now named better:

-  goalByOrganizationIdAndTeamIdAndGoalUuid: Goal
+  organizationTeamGoal: Goal

Unique relations get shorter-named reverse field.

This was a bug (or, really, an omission) in v5.

For this table:

create table mascots (
    id serial primary key,
    company_id int unique not null references companies,
    name text not null
);

Previously we had the plural relationship simplified:

-  mascotsByCompanyId(
+  mascots(

But the singular was not. This update changes the singular too:

-  mascotByCompanyId: Mascot
+  mascot: Mascot

v5.0.0-beta.1

v5.0.0-beta.0

More advanced guesses at field names for reverse relations. Ability to omit list
suffix, simplify patch names, turn on/off simplifying of the 'all' from
'allUsers', ability to change the 'ById' primary key fields to not have that
suffix and instead have the node ID fetchers have a suffix.

v3.0.0

Simplifies naming in more of the schema.

v2.0.0

Breaking change: single relation names based on a single key are now named after
the key rather than the target table so long as the key is of the form foo_id,
foo_uuid.

create table posts (
  id serial primary key,
  author_id int not null references users,
  body text not null
);
 type Post {
   nodeId: ID!
   id: Int!
   authorId: Int!
-  user: User
+  author: User
   body: String!
 }

v1.0.0

Initial release

Don't miss a new crystal release

NewReleases is sending notifications on new releases.