Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

graphile-config

graphile204.6kMIT0.0.1-beta.15TypeScript support: included

Standard plugin interface and helpers to be used across the Graphile stack.

graphile, plugin, graphite

readme

🔮 Graphile's Crystal Monorepo

GitHub Sponsors Patreon sponsor button Discord chat room Follow

At Graphile we love GraphQL so much we named ourself for our love of it! This repository houses many of the Graphile packages that relate to GraphQL (or relate to the packages that relate to GraphQL, or relate to those package...); the two headline projects are Grafast and PostGraphile but there's many other packages, a fair few of which can be used independently - see below for more details.

Grafast: A cutting-edge planning and execution engine for GraphQL.js ─ use this as a drop-in replacement for the execute method from GraphQL.js and by moving from traditional resolvers to Grafast "plan resolvers" you'll be able to leverage the declarative nature of GraphQL requests to execute your business logic in the most efficient way, leading to reduced server load and happier customers. Use this if you're building your own GraphQL schemas and want the best performance and efficiency without having to put much extra effort in.

PostGraphile: An incredibly low-effort way to build a well structured and high-performance GraphQL API backed primarily by a PostgreSQL database. Our main focusses are performance, automatic best-practices and customisability/extensibility. Use this if you have a PostgreSQL database and you want to use it as the "source of truth" for an auto-generated GraphQL API (which you can still make significant changes to). NOTE: thanks to graphile-export you can also use this as a starting point for an API that you then manage yourself.

➡️ For PostGraphile V4 see the legacy branch

Project summaries

Here's a rough breakdown of the main packages:

  • grafast - standalone cutting-edge planning and execution engine for GraphQL; see above for full description.
  • graphile-export - a package that can (under the right circumstances) export an in-memory dynamically-constructed GraphQL schema to raw JavaScript source code that can be imported and executed
  • jest-serializer-graphql-schema - a simple Jest serializer that understands GraphQL schemas and thus does not fill snapshots with \"\"\" etc.
  • graphile-config - a module that handles the plugins, presets and configuration files for Graphile software - a universal configuration layer.
  • graphile-build - a system for building a GraphQL.js schema from "plugins", particularly useful for auto-generated GraphQL APIs (e.g. PostGraphile uses this) but also useful for hand-rolled schemas that have a lot of modular but widely-used concerns such as connections, naming, etc.
    • graphile-build-pg - plugins for graphile-build that understand @dataplan/pg (i.e. PostgreSQL) services and can generate types, relations, mutations, etc for these database resources.
  • @graphile/lru - an obsessively performant least-recently-used cache (possibly the fastest general purpose LRU cache in Node.js) with a ridiculously tiny feature set; you almost certainly want @isaacs' lru-cache instead of this.
  • pg-sql2 - a library for building highly dynamic SQL-injection-proof PostgreSQL queries using tagged template literals.
  • pg-introspection - a strongly typed introspection library for PostgreSQL, generated from the PostgreSQL documentation to provide up-to-date details of each introspection field.
  • postgraphile - pulls most of the above technologies together; see above for full description.

Crowd-funded open-source software

To help us develop this software sustainably, we ask all individuals and businesses that use it to help support its ongoing maintenance and development via sponsorship.

Click here to find out more about sponsors and sponsorship.

And please give some love to our featured sponsors 🤩:

The Guild
The Guild
*
Steelhead
Steelhead
*

* Sponsors the entire Graphile suite

Why the "crystal" monorepo?

Originally what is now Grafast (and was previously DataPlanner) was known by the codename "Graphile Crystal." This lead us to use the 🔮 emoji to represent the project in secret before we announced it publicly, as a codeword for those in the know. Now that Grafast is the name for our planning and execution engine and we needed a name for the monorepo that wasn't too GraphQL specific (since there are things in here that aren't strictly related to GraphQL) and we figured that calling it the Crystal monorepo would honour our original nickname for the project. Rumours that the name was inspired by the maintainers' crystal wedding anniversary are greatly exaggerated.

changelog

graphile-config

0.0.1-beta.15

Patch Changes

0.0.1-beta.14

Patch Changes

0.0.1-beta.13

Patch Changes

0.0.1-beta.12

Patch Changes

  • #2240 d13b76f0f Thanks @benjie! - Adds MiddlewareHandlers<TActivities> type to help with adding middleware to configs

  • #2253 b167bd849 Thanks @benjie! - 🚨 {} is no longer a valid GraphileConfig.ResolvedPreset; use resolvePreset({})

    Also: adds resolvePreset(preset) and deprecates resolvePresets(presets).

  • #2250 6a13ecbd4 Thanks @benjie! - Add support for 'preset.lib' which can be used to store global module references to help avoid the dual package hazard.

0.0.1-beta.11

Patch Changes

0.0.1-beta.10

Patch Changes

  • #2188 cc0941731 Thanks @benjie! - Overhaul the way in which graphile-config presets work such that including a preset at two different layers shouldn't result in unexpected behavior.

  • #2155 8b472cd51 Thanks @benjie! - disablePlugins now supports TypeScript auto-completion of known plugin names. Other names are still accepted without error, so this is just a minor DX improvement rather than type safety.

  • #2160 9cd9bb522 Thanks @benjie! - Add support for lists of hook objects, so that the same hook can be applied multiple times in the same plugin but with different priorities.

0.0.1-beta.9

Patch Changes

  • #2071 582bd768f Thanks @benjie! - GrafastExecutionArgs now accepts resolvedPreset and requestContext directly; passing these through additional arguments is now deprecated and support will be removed in a future revision. This affects:

    • grafast()
    • execute()
    • subscribe()
    • hookArgs()

    graphile-config has gained a middleware system which is more powerful than it's AsyncHooks system. Old hooks can be emulated through the middleware system safely since middleware is a superset of hooks' capabilities. applyHooks has been renamed to orderedApply (because it applies to more than just hooks), calling applyHooks will still work but is deprecated.

    🚨 grafast no longer automatically reads your graphile.config.ts or similar; you must do that yourself and pass the resolvedPreset to grafast via the args. This is to aid in bundling of grafast since it should not need to read from filesystem or dynamically load modules.

    grafast no longer outputs performance warning when you set GRAPHILE_ENV=development.

    🚨 plugin.grafast.hooks.args is now plugin.grafast.middleware.prepareArgs, and the signature has changed - you must be sure to call the next() function and ctx/resolvedPreset can be extracted directly from args:

     const plugin = {
       grafast: {
    -    hooks: {
    +    middleware: {
    -      args({ args, ctx, resolvedPreset }) {
    +      prepareArgs(next, { args }) {
    +        const { requestContext: ctx, resolvedPreset } = args;
             // ...
    +        return next();
           }
         }
       }
     }

    Many more middleware have been added; use TypeScript's autocomplete to see what's available until we have proper documentation for them.

    plugin.grafserv.hooks.* are still supported but deprecated; instead use middleware plugin.grafserv.middleware.* (note that call signatures have changed slightly, similar to the diff above):

    • hooks.init -> middleware.setPreset
    • hooks.processGraphQLRequestBody -> middleware.processGraphQLRequestBody
    • hooks.ruruHTMLParts -> middleware.ruruHTMLParts

    A few TypeScript types related to Hooks have been renamed, but their old names are still available, just deprecated. They will be removed in a future update:

    • HookObject -> FunctionalityObject
    • PluginHook -> CallbackOrDescriptor
    • PluginHookObject -> CallbackDescriptor
    • PluginHookCallback -> UnwrapCallback

0.0.1-beta.8

Patch Changes

  • #2048 db8ceed0f Thanks @benjie! - Help detect more invalid presets and plugins (bad imports) by forbidding keys starting with a capital or the key default.

0.0.1-beta.7

Patch Changes

0.0.1-beta.6

Patch Changes

  • #1892 0df5511ac Thanks @benjie! - Fix plugin ordering bug that ignored before/after when there was no provider; this now means PgSmartTagsPlugin is correctly loaded before PgFakeConstraintPlugin, fixing the postgraphile.tags.json5 file.

0.0.1-beta.5

Patch Changes

  • #1877 8a0cdb95f Thanks @benjie! - Move 'declare global' out of 'interfaces.ts' and into 'index.ts' or equivalent. Should make TypeScript more aware of these types.

0.0.1-beta.4

Patch Changes

  • 7aef73319 Thanks @benjie! - TypeScript tweak to use readonly array in one place.

0.0.1-beta.3

Patch Changes

0.0.1-beta.2

Patch Changes

0.0.1-beta.1

Patch Changes

0.0.1-alpha.7

Patch Changes

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

0.0.1-alpha.6

Patch Changes

0.0.1-alpha.5

Patch Changes

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

0.0.1-alpha.4

Patch Changes

0.0.1-alpha.3

Patch Changes

  • #344 adc7ae5e0 Thanks @benjie! - Detect presets that look like plugins and vice versa and throw error.

0.0.1-alpha.2

Patch Changes

0.0.1-alpha.1

Patch Changes

0.0.1-1.2

Patch Changes

  • #297 b4eaf89f4 Thanks @benjie! - AsyncHooks can now execute synchronously if all registered hooks are synchronous. May impact ordering of fields/types in GraphQL schema.

0.0.1-1.1

Patch Changes

0.0.1-0.6

Patch Changes

  • #233 11e7c12c5 Thanks @benjie! - Solve mutation issue in plugin ordering code which lead to heisenbugs.

0.0.1-0.5

Patch Changes

0.0.1-0.4

Patch Changes

  • #184 842f6ccbb Thanks @benjie! - Handle array-to-object issue in graphile-config when multiple presets set an array key.

0.0.1-0.3

Patch Changes

  • #176 19e2961de Thanks @benjie! - Better graphile.config.* compatibility with ESM-emulation, so 'export default preset;' should work in TypeScript even if outputting to CommonJS.

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

0.0.1-0.2

Patch Changes

  • 9b296ba54 - More secure, more compatible, and lots of fixes across the monorepo

0.0.1-0.1

Patch Changes

0.0.1-0.0

Patch Changes