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

Outdated chalk dependency breaks Postgraphile when running with --disable-proto=delete or using Deno #1897

Closed
conradoac opened this issue Dec 24, 2023 · 3 comments · Fixed by #1902

Comments

@conradoac
Copy link

Summary

I have been trying to run Postgraphile using Deno with no success.

After some research I realized the same issue occurs when running it using Node.js with the --disable-proto=delete option.

Steps to reproduce

Run the following command:

node --disable-proto=delete main.js

main.js

const express = require("express");
const postgraphile = require("postgraphile");

const app = express();

app.use(
  postgraphile.default(
    "DB_URL",
    "DB_SCHEMA",
    {
      watchPg: true,
      graphiql: true,
      enhanceGraphiql: true,
    }
  )
);

app.listen(8000, () => {
  console.log("Listening on port 8000...");
});

Expected results

App won't crash, the GraphQL API would build based on my db schema.

Actual results

A serious error occurred when building the initial schema. Exiting because `retryOnInitFail` is not set. Error details:

TypeError: highlightOrNot is not a function
    at D:\Projects\agd\test\node_modules\graphile-build-pg\node8plus\plugins\PgBasicsPlugin.js:205:17
    at Array.forEach (<anonymous>)
    at D:\Projects\agd\test\node_modules\graphile-build-pg\node8plus\plugins\PgBasicsPlugin.js:204:16
    at Array.reduce (<anonymous>)
    at Object.sqlCommentByAddingTags (D:\Projects\agd\test\node_modules\graphile-build-pg\node8plus\plugins\PgBasicsPlugin.js:200:37)
    at D:\Projects\agd\test\node_modules\graphile-build-pg\node8plus\plugins\PgConnectionArgOrderBy.js:46:159
    at Array.forEach (<anonymous>)
    at D:\Projects\agd\test\node_modules\graphile-build-pg\node8plus\plugins\PgConnectionArgOrderBy.js:27:38
    at SchemaBuilder.applyHooks (D:\Projects\agd\test\node_modules\graphile-build\node8plus\SchemaBuilder.js:264:20)
    at SchemaBuilder.createBuild (D:\Projects\agd\test\node_modules\graphile-build\node8plus\SchemaBuilder.js:325:10)

Possible Solution

It seems the issue is related to an outdated chalk dependency.

The following discussions helped me reach this conclusion:

Additional context

  • My main goal here is to use Deno (especially Deno Deploy) and Postgraphile. This would be amazing. Really, really fast way to have a full GraphQL API deployed and running.
  • I've tried changing locally the file where the error happens (PgBasicsPlugin) and it fixed the problem.
  • There is a similar issue with graphile-migrate. Would be really nice to use Deno + Migrate as well.

If you would like to try it with Deno, install Deno and run the following command:

deno run -A main.js

NOTE: When using Deno you have to explicitly allow security sensitive functions. The -A will grant all permissions. More info here.

main.js

// @deno-types="npm:@types/express@4.17.15"
import express from "npm:express@4.18.2";
import postgraphile from "npm:postgraphile@4.13.0";

const app = express();

app.use(
  postgraphile.default(
    "DB_URL",
    "DB_SCHEMA",
    {
      watchPg: true,
      graphiql: true,
      enhanceGraphiql: true,
    }
  )
);

app.listen(8000, () => {
  console.log("Listening on port 8000...");
});
@conradoac conradoac changed the title Outdated chalk dependency breaks Postgraphile when running with --disable-proto=delete or using Deno Outdated chalk dependency breaks Postgraphile when running with --disable-proto=delete or using Deno Dec 24, 2023
@benjie
Copy link
Member

benjie commented Jan 3, 2024

Please could you test with postgraphile@beta (PostGraphile V5)? I'm unlikely to make changes to PostGraphile V4 that involve major version bumps of dependencies just to accomodate alternative runtimes.

@benjie
Copy link
Member

benjie commented Jan 5, 2024

Can confirm that V5's test suite at least is fine with this option.

@conradoac
Copy link
Author

Great. I'm excited to migrate to V5. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants