Skip to content

Latest commit

 

History

History
2115 lines (1701 loc) · 98.7 KB

File metadata and controls

2115 lines (1701 loc) · 98.7 KB

graphile-build-pg

5.0.0-beta.25

Patch Changes

5.0.0-beta.24

Patch Changes

5.0.0-beta.23

Patch Changes

5.0.0-beta.22

Patch Changes

5.0.0-beta.21

Patch Changes

5.0.0-beta.20

Patch Changes

5.0.0-beta.19

Patch Changes

5.0.0-beta.18

Patch Changes

5.0.0-beta.17

Patch Changes

5.0.0-beta.16

Patch Changes

5.0.0-beta.15

Patch Changes

5.0.0-beta.14

Patch Changes

5.0.0-beta.13

Patch Changes

5.0.0-beta.12

Patch Changes

5.0.0-beta.11

Patch Changes

  • #1770 9a84bc6dd Thanks @benjie! - Fix issues around enum tables: indicate when an enum table codec replaces a regular attribute codec, expose helpers for working with enum tables, and don't exclude enum table references when using the Relay preset.

  • #1769 b728d7fb9 Thanks @benjie! - Fix error message when ref is used with no foreign key.

  • #1774 7d55d2c34 Thanks @benjie! - Add preset.gather.pgIdentifiers setting (values: 'qualified' or 'unqualified'); if set to 'unqualified' then we will not add the schema name to table or function identifiers - it's up to you to ensure they're present in the search_path (which you can set via pgSettings on a per-request basis).

  • Updated dependencies [4a4d26d87, b2bce88da, 861a8a306, 9a84bc6dd, b728d7fb9]:

5.0.0-beta.10

Patch Changes

5.0.0-beta.9

Patch Changes

5.0.0-beta.8

Patch Changes

5.0.0-beta.7

Patch Changes

5.0.0-beta.6

Patch Changes

5.0.0-beta.5

Patch Changes

5.0.0-beta.4

Patch Changes

5.0.0-beta.3

Patch Changes

5.0.0-beta.2

Patch Changes

5.0.0-beta.1

Patch Changes

5.0.0-alpha.20

Patch Changes

5.0.0-alpha.19

Patch Changes

  • #433 5491e10b0 Thanks @benjie! - Improve error messages from custom string scalars when they cannot be parsed as a string.

  • #434 a9561d62d Thanks @benjie! - Deprecate preset.gather.pgJwtType (tuple), instead use preset.gather.pgJwtTypes which expects a string and parses it similar to the PostgreSQL parser (and also allows multiple types to be specified).

  • #433 232885703 Thanks @benjie! - Change type of pgJwtSecret and pgJwtSignOptions from any to the correct types.

  • #438 db19ed9c3 Thanks @benjie! - When using @interface mode:relational, don't add pointless relationships from concrete type back to abstract or from abstract to related concrete types.

  • #438 31e776e03 Thanks @benjie! - Fix spurious error relating to connection for @interface type:relational

  • #436 055c4e438 Thanks @benjie! - Fix inflection of computed column field names in secondary schemas when using the V5 preset. Also, use underscores instead of dashes for the serviceName/schemaName separator for the names of the function resources, so that they can be typed manually rather than having to use string properties like const { ["myService-mySchema-my_function_name"]: myFunctionResource } = pgRegistry.pgResources

  • #435 cf32f0397 Thanks @benjie! - Fix bug in listOfCodec causing wrong extensions to be used in non-deterministic manner (thanks to @jvandermey for finding the bug and helping to track it down).

  • #428 57d88b5fa Thanks @benjie! - Fix bug exporting schema, and importing schema with __assertStep.

  • #438 a22830b2f Thanks @benjie! - Plugin name now automatically used in provides for every hook, allowing ordering hooks before/after their equivalents in other plugins.

  • #428 9695c65f8 Thanks @benjie! - Optimize away some unnecessary content from graphile-exported schema

  • Updated dependencies [ea003ca3a, 5491e10b0, cf32f0397, 57d88b5fa, a22830b2f, 9f87a26b1]:

5.0.0-alpha.18

Patch Changes

  • #421 415f436a0 Thanks @benjie! - @notNull is now respected in PgAttributesPlugin for outputs as well as inputs.

  • #421 5b8e46a8a Thanks @benjie! - Breaking for types: move Pg*Tags to GraphileBuild.Pg*Tags for easier declaration merging

  • #421 bb64c090d Thanks @benjie! - New build.pgResolveOutputType helper exported to aid plugins determining GraphQL output type from a codec (taken from PgAttributesPlugin).

5.0.0-alpha.17

Patch Changes

5.0.0-alpha.16

Patch Changes

5.0.0-alpha.15

Patch Changes

  • #417 e7dd2e039 Thanks @benjie! - codec is now baked into NodeId handlers (rather than using codecName and looking that up in codecs). All related APIs have thus simplified, e.g. the step node(codecs, handler, $id) is now node(handler, $id), etc. TypeScript should point out any issues you have hopefully.

  • #417 f115b6fb2 Thanks @benjie! - Export parseDatabaseIdentifier

  • #417 881672305 Thanks @benjie! - deepEval has been renamed to applyTransforms

  • #418 9ab2adba2 Thanks @benjie! - Overhaul peerDependencies and dependencies to try and eliminate duplicate modules error.

  • #410 4eda0cd57 Thanks @benjie! - Use a single behavior check per location.

    In the past two weeks I added a few behavior strings like array:attribute:filterBy (a scoped form of attribute:filterBy to only be used by attributes that were arrays); however I've realised that this will require plugin authors to implement all the same logic to figure out what type an attribute is in order to then see if it has the relevant behavior. This goes against the design of the behavior system, and makes plugin authors' lives harder. So I've reverted this, and instead used the entityBehaviors system to add or remove the base attribute:filterBy (etc) behavior depending on what the type of the attribute is.

  • Updated dependencies [e7dd2e039, 620f9e07e, 1882e0185, 881672305, e5012f9a1, 9ab2adba2, 47f6f018b, ff4395bfc, 502b23340, 4eda0cd57]:

5.0.0-alpha.14

Patch Changes

5.0.0-alpha.13

Patch Changes

  • #402 70b2c3900 Thanks @benjie! - pgCodecAttribute behavior now uses attributeName rather than attribute spec in the callback (BREAKING)

  • #402 37d829b89 Thanks @benjie! - Ability to control whether the nodeId or regular column CRUD mutations are used

  • #402 ff91a5660 Thanks @benjie! - Added postgraphile/presets/relay preset:

    • Hides primary key columns from output schema, and includes id: ID instead
    • Hides foreign key columns from output schema, expecting you to use the relation instead
    • Hides columns that are part of the primary key from update/delete mutations (but still present for create if the column is writeable - it shouldn't be)
    • Hides columns that are part of a foreign key from CRUD mutations/filters, instead exposes the ID for the remote side of the relation
    • Does not allow ordering by individual primary key columns (though you can still order by PRIMARY_KEY_ASC/DESC)
    • Does not allow ordering by individual foreign key columns
    • Turns off the row fetchers that don't use the node ID
    • Turns off the CRUD mutations that don't use the node ID
    • Functions can now use @arg0variant nodeId to indicate the first argument (increase the 0 for other arguments) should accept a node ID (this currently only works where the argument type is a table type)
    • Removes relations from mutation payloads, these should be traversed via the record instead (they're redundant)

    Most of these changes are reversible, so for example if you really want to turn back on Query.userByUsername you can do so by adding the +connection behavior to the "unique username" constraint on the users table.

  • #402 644938276 Thanks @benjie! - Use file:// URLs in import() to fix compatibility with Windows (e.g. when loading graphile.config.mjs)

  • #402 339cb005e Thanks @benjie! - Remove relations from mutation payloads (unless using V4 preset) - they're redundant.

  • Updated dependencies [644938276, 47365f0df]:

5.0.0-alpha.12

Patch Changes

5.0.0-alpha.11

Patch Changes

  • #349 a94f11091 Thanks @benjie! - Overhaul behavior system

    Previously the behavior system worked during the schema building process, inside the various schema hooks. So looking at the behavior of a relation might have looked like:

    GraphQLObjectType_fields_field(field, build, context) {
      const relation = context.scope.pgRelationOrWhatever;
    
      // Establish a default behavior, e.g. you might give it different default behavior
      // depending on if the remote table is in the same schema or not
      const defaultBehavior = someCondition(relation) ? "behavior_if_true" : "behavior_if_false";
    
      // Now establish the user-specified behavior for the entity, inheriting from all the
      // relevant places.
      const behavior = getBehavior([
        relation.remoteResource.codec.extensions,
        relation.remoteResource.extensions,
        relation.extensions
      ]);
    
      // Finally check this behavior string against `behavior_to_test`, being sure to apply
      // the "schema-time smart defaulting" that we established in `defaultBehavior` above.
      if (build.behavior.matches(behavior, "behavior_to_test", defaultBehavior)) {
        doTheThing();
      }

    This meant that each plugin might treat the behavior of the entity different - for example postgraphile-plugin-connection-filter might have a different someCondition() under which the "filter" behavior would apply by default, whereas the built in condition plugin might have a different one.

    Moreover, each place needs to know to call getBehavior with the same list of extension sources in the same order, otherwise subtle (or not so subtle) differences in the schema would occur.

    And finally, because each entity doesn't have an established behavior, you can't ask "what's the final behavior for this entity" because it's dynamic, depending on which plugin is viewing it.

    This update fixes all of this; now each entity has a single behavior that's established once. Each plugin can register entityBehaviors for the various behavior entity types (or global behaviors which apply to all entity types if that makes more sense). So the hook code equivalent to the above would now be more like:

    GraphQLObjectType_fields_field(field, build, context) {
      const relation = context.scope.pgRelationOrWhatever;
      // Do the thing if the relation has the given behavior. Simples.
      if (build.behavior.pgCodecRelationMatches(relation, "behavior_to_test")) {
        doTheThing();
      }

    This code is much more to the point, much easier for plugin authors to implement, and also a lot easier to debug since everything has a single established behavior now (except refs, which aren't really an entity in their own right, but a combination of entities...).

    These changes haven't changed any of the schemas in the test suite, but they may impact you. This could be a breaking change - so be sure to do a schema diff before/after this.

  • #355 1fe47a2b0 Thanks @benjie! - MAJOR BREAKING CHANGE: implicit application of args/input fields has been removed.

    Previously we would track the fieldArgs that you accessed (via .get(), .getRaw() or .apply()) and those that you did not access would automatically have their applyPlan called, if they had one. This isn't likely to be particularly useful for pure Grafast users (unless they want to adopt this pattern) but it's extremely useful for plugin-based schemas as it allows plugins to add arguments that can influence their field's plan without having to wrap the field's plan resolver function. This is fairly critical, otherwise each behavior added (first:, condition:, orderBy:, filter:, ignoreArchived:, etc etc) would wrap the plan resolver with another function layer, and they would get messy.

    However, implicit is rarely good. And it turns out that it severely limited what I wanted to do for improving the fieldArgs APIs.

    I decided to remove this implicit functionality by making it more explicit, so now args/input fields can specify the relevant autoApplyAfterParent{Plan,SubscribePlan,InputPlan,ApplyPlan}: true property and we'll only apply them at a single level.

    From a user perspective, little has changed. From a plugin author perspective, if you were relying on the implicit applyPlan then you should now add the relevant autoApply* property next to your applyPlan method.

  • #363 bcfffd5fe Thanks @benjie! - Fix bug causing @foreignKey relation to not show up under rare circumstances (by updating PgRelationsPlugin to use codec, not resource, as the primary entity).

  • #362 e443db39b Thanks @benjie! - Use original case for table resource names.

  • Updated dependencies [339fe20d0, 56237691b, ed1982f31, a94f11091, 1fe47a2b0, 198ac74d5, 6878c589c, 2ac706f18, 77e011294, dad4d4aae, e443db39b]:

5.0.0-alpha.10

Patch Changes

5.0.0-alpha.9

Patch Changes

5.0.0-alpha.8

Patch Changes

5.0.0-alpha.7

Patch Changes

5.0.0-alpha.6

Patch Changes

5.0.0-alpha.5

Patch Changes

5.0.0-alpha.4

Patch Changes

5.0.0-alpha.3

Patch Changes

5.0.0-alpha.2

Patch Changes

5.0.0-alpha.1

Patch Changes

5.0.0-1.3

Patch Changes

5.0.0-1.2

Patch Changes

5.0.0-1.1

Patch Changes

  • #279 2df36c5a1 Thanks @benjie! - description moved out of extensions to live directly on all the relevant entities.

  • #287 c5d89d705 Thanks @benjie! - Fix the type definition of GatherHooks to allow plugins to indicate individual gather hook ordering.

  • #279 a73f9c709 Thanks @benjie! - PgConnectionArgFirstLastBeforeAfterPlugin is now PgFirstLastBeforeAfterArgsPlugin (because it applies to lists as well as connections). PgInsertStep/pgInsert()/PgUpdateStep/pgUpdate()/PgDeleteStep/pgDelete() are now PgInsertSingleStep/pgInsertSingle()/PgUpdateSingleStep/pgUpdateSingle()/PgDeleteSingleStep/pgDeleteSingle() (to make space to add a future bulk API if we want to). config.schema.orderByNullsLast is now config.schema.pgOrderByNullsLast for consistency (V4 preset users are unaffected). Lots of field scopes in graphile-build-pg have been updated to incorporate field into their names.

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

  • #259 c22dcde7b Thanks @benjie! - Renamed recordType codec factory to recordCodec. recordCodec() now only accepts a single object argument. Renamed enumType codec factory to enumCodec. enumCodec() now only accepts a single object argument. Rename listOfType to listOfCodec.

    Massive overhaul of PgTypeCodec, PgTypeColumn and PgTypeColumns generics - types should be passed through much deeper now, but if you reference any of these types directly you'll need to update your code.

  • #285 bd37be707 Thanks @benjie! - Single table inheritance no longer exposes non-shared columns via condition/order, and also only exposes the relationships on the types where they are appropriate.

  • #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 d951897ee Thanks @benjie! - Add extensions.pg to Postgres function resources (makes it easier for plugins to hook them).

  • #286 366b166dc Thanks @benjie! - Add detection for @ref that is missing singular, fix docs and test schema and add tests for same.

  • #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
  • #268 a14cf5f4c Thanks @benjie! - PgV4NoIgnoreIndexesPlugin is now PgIndexBehaviorsPlugin, moved to graphile-build-pg, and is enabled by default

  • Updated dependencies [2df36c5a1, c5d89d705, a73f9c709, ae304b33c, ef42d717c, d5312e6b9, 22ec50e36, 0f4709356, c22dcde7b, bd37be707, f8954fb17, 96b0bd14e, f93c79b94, fbf1da26a, 53e164cbc, c564825f3, 261eb520b, 395b4a2dd]:

5.0.0-0.34

Patch Changes

5.0.0-0.33

Patch Changes

5.0.0-0.32

Patch Changes

5.0.0-0.31

Patch Changes

5.0.0-0.30

Patch Changes

5.0.0-0.29

Patch Changes

5.0.0-0.28

Patch Changes

  • #218 f2c1423fb Thanks @benjie! - Option for @foreignKey smart tag to have unique auto-created for it to ease transition from V4: { gather: { pgFakeConstraintsAutofixForeignKeyUniqueness: true } }

  • #219 b58f5dfac Thanks @benjie! - Rename GraphileBuild.GraphileBuildGatherOptions to GraphileBuild.GatherOptions. Rename GraphileBuild.GraphileBuildInflectionOptions to GraphileBuild.InflectionOptions.

  • Updated dependencies [b58f5dfac]:

5.0.0-0.27

Patch Changes

5.0.0-0.26

Patch Changes

5.0.0-0.25

Patch Changes

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

5.0.0-0.24

Patch Changes

  • 5812ad277 - Deal better with NodePlugin being disabled.

5.0.0-0.23

Patch Changes

5.0.0-0.22

Patch Changes

5.0.0-0.21

Patch Changes

5.0.0-0.20

Patch Changes

5.0.0-0.19

Patch Changes

5.0.0-0.18

Patch Changes

  • 0ab95d0b1 - Update sponsors.

  • #190 652cf1073 Thanks @benjie! - 🚨 Breaking changes around types and postgres configuration:

    • GraphileBuild.GraphileResolverContext renamed to Grafast.Context
    • GraphileConfig.GraphQLRequestContext renamed to Grafast.RequestContext
    • Grafast.PgDatabaseAdaptorOptions renaed to GraphileConfig.PgDatabaseAdaptorOptions
    • @dataplan/pg/adaptors/node-postgres is now @dataplan/pg/adaptors/pg due to the bizarre naming of PostgreSQL clients on npm - we've decided to use the module name as the unique identifier
    • makePgConfigs:
      • is now makePgConfig (singular) - so you'll need to wrap it in an array where you use it
      • no longer exported by @dataplan/pg (because it depended on pg) - instead each adaptor exposes this helper - so import from @dataplan/pg/adaptors/node-postgres
      • accepts an object parameter containing {connectionString, schemas, superuserConnectionString}, rather than multiple string parameters
    • makeNodePostgresWithPgClient -> makePgAdaptorWithPgClient
    • postgraphile CLI will now try and respect the adaptor stated in your preset when overriding connection arguments
    • Removed Grafast.RequestContext.httpRequest and instead use Grafast.RequestContext.node.req/res; all server adaptors should implement this if appropriate
  • #192 80091a8e0 Thanks @benjie! - - Conflicts in pgConfigs (e.g. multiple sources using the same 'name') now detected and output

    • Fix defaults for pgSettingsKey and withPgClientKey based on config name
    • makePgConfig now allows passing pgSettings callback and pgSettingsForIntrospection config object
    • Multiple postgres sources now works nicely with multiple makePgConfig calls
  • Updated dependencies [0ab95d0b1, af9bc38c8, 4783bdd7c, 652cf1073, 80091a8e0]:

5.0.0-0.17

Patch Changes

  • 72bf5f535 - Overhaul the behavior system (see https://postgraphile.org/postgraphile/next/behavior).

    • Adds schema.defaultBehavior configuration option to save having to write a plugin for such a simple task
    • Changes a bunch of behavior strings:
      • (query|singularRelation|manyRelation|queryField|typeField):(list|connection|single) -> $1:source:$2 (e.g. query:list -> query:source:list)
    • Checks for more specific behaviors, e.g. source:update or constraint:source:update or attribute:update rather than just update
    • Updates every change to getBehavior so that it follows the relevant chain (e.g. codec -> source -> relation for relations, similar for other types)
    • More helpful error message when -insert prevents functions with input arguments working
    • Throw an error if you try and use "create" scope (because we use insert/update/delete not create/update/delete)
  • Updated dependencies [72bf5f535]:

5.0.0-0.16

Patch Changes

5.0.0-0.15

Patch Changes

  • #183 ebb24895c Thanks @benjie! - Fix bug when handling stable void functions

  • #181 d3cba220c Thanks @benjie! - *FieldName smart tags are now used verbatim rather than being piped through inflection.camelCase(...) - you've explicitly stated a 'field name' so we should use that. This may be a breaking change for you if your field names are currently different before/after they are camelCase'd.

  • #183 3eb9da95e Thanks @benjie! - Fix potential construction loop on failure to construct a type

  • Updated dependencies [3eb9da95e]:

5.0.0-0.14

Patch Changes

5.0.0-0.13

Patch Changes

5.0.0-0.12

Patch Changes

5.0.0-0.11

Patch Changes

5.0.0-0.10

Patch Changes

5.0.0-0.9

Patch Changes

5.0.0-0.8

Patch Changes

5.0.0-0.7

Patch Changes

5.0.0-0.6

Patch Changes

5.0.0-0.5

Patch Changes

5.0.0-0.4

Patch Changes

5.0.0-0.3

Patch Changes

5.0.0-0.2

Patch Changes

5.0.0-0.1

Patch Changes