Skip to content

How can I add this filter when running the 'npx postgraphile' ? #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
duncangroenewald opened this issue Apr 21, 2025 · 0 comments
Open

Comments

@duncangroenewald
Copy link

duncangroenewald commented Apr 21, 2025

How can I include this filter when running using the basic 'npx postgraphile' client example using a graphile.config.mjs file with a preset defined.

This does not seem to work

npx postgraphile --append-plugins postgraphile-plugin-connection-filter
Is it possible to include this in the graphile.config.mjs file and if so how ?

This doesn't seem to work.

import { PostGraphileAmberPreset } from "postgraphile/presets/amber";
import { makePgService } from "postgraphile/adaptors/pg";
import ConnectionFilterPlugin  from "postgraphile-plugin-connection-filter";

/** @type {GraphileConfig.Preset} */
const preset = {
  extends: [PostGraphileAmberPreset],
  plugins: [
    /* Add plugins here, e.g.: */
    ConnectionFilterPlugin,
  ],
  pgServices: [makePgService({ connectionString: "postgresql://user:pwd@localhost:5432/dbname",
                               schemas: "dbschemaname",
                               port: 5679,
                               superuserConnectionString: "postgresql://user:pwd@localhost:5432/dbname"
   })],
  grafserv: { watch: false },
  schema: {
    /* options for the schema build phase, e.g.: */
    retryOnInitFail: true,
    exportSchemaSDLPath: `${process.cwd()}/latestSchema-dbname.graphql`,
    exportSchemaIntrospectionResultPath: `${process.cwd()}/latestSchema-dbname.json`,
    sortExport: true,
  }
};

export default preset

Errors:

postgraphile/node_modules/graphile-config/dist/resolvePresets.js:180
        throw new Error(`Error occurred when resolving preset:\n  ${String(e).replace(/\n/g, "\n  ")}\nPreset: ${inspect(preset)}`);
              ^

Error: Error occurred when resolving preset:
  Error: Expected plugin, but found '[Function: PostGraphileConnectionFilterPlugin]'
Preset: {
  extends: [ { extends: [Array], plugins: [Array] } ],
  plugins: [ [Function: PostGraphileConnectionFilterPlugin] ],
  pgServices: [
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant