Skip to content
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

Explain how to require @graphile/postgis in library mode with CommonJS #33

Open
hengnee opened this issue Jan 24, 2020 · 4 comments
Open
Labels
good first issue Good for newcomers

Comments

@hengnee
Copy link

hengnee commented Jan 24, 2020

Hi, I'm not sure if this is the right place to ask such a question but I do apologies in advance.

but doing the following in my code:

const PostgisPlugin =  require("@graphile/postgis");
...
const postgraphileOpt = {
  watchPg: true,
  retryOnInitFail: true,
  graphiql: true,
  enhanceGraphiql: true,
  graphiqlRoute: "/schema",
  enableCors: true,
  disableQueryLog: true,
  appendPlugins: [ConnectionFilterPlugin, PostgisPlugin]
};

produced this error:

$ Error: Option 'appendPlugins' should be an array of functions, found 'object'  at index 1 ...

May I know if I'm doing it completely wrong or should I not have used it within the library but in the CLI instead?

@benjie
Copy link
Member

benjie commented Jan 24, 2020

Ah, this is because you're using CommonJS; to solve it, change the appendPlugins line to:

  appendPlugins: [
    ConnectionFilterPlugin,
    PostgisPlugin.default || PostgisPlugin,
  ]

Thanks!

@benjie benjie changed the title Trouble using require as PostGraphile Library Explain how to require @graphile/postgis in library mode with CommonJS Jan 24, 2020
@benjie benjie added the good first issue Good for newcomers label Jan 24, 2020
@crooy
Copy link

crooy commented May 30, 2021

Would setting esModuleInterop not solve this?

@nodesocket
Copy link

Just spent 10 minutes trying to figure this out. Would be nice to add to the README.md.

const extPostgis = require('@graphile/postgis');

...
appendPlugins: [extPgSimplifyInflector, extPostgis.default || extPostgis],
...

@benjie
Copy link
Member

benjie commented Dec 27, 2021

PR to README welcome 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants