Skip to content

EXPORT recently broken -- possibly related to pg-aggregates? #2445

Closed
@nckswt

Description

@nckswt

Summary

I recently update to latest packages:

--- a/packages/operations-api/package.json
+++ b/packages/operations-api/package.json
@@ -29,8 +29,8 @@
     "@aws-sdk/client-dynamodb": "3.658.1",
     "@aws-sdk/lib-dynamodb": "3.658.1",
     "@aws-sdk/client-api-gateway": "3.658.1",
-    "@graphile/pg-aggregates": "0.2.0-beta.7",
-    "@graphile/simplify-inflection": "8.0.0-beta.5",
+    "@graphile/pg-aggregates": "0.2.0-beta.8",
+    "@graphile/simplify-inflection": "8.0.0-beta.6",
     "@tailosinc/borg-event-client-kinesis": "^1.29.3",
     "@tailosinc/borg-event-common": "^1.37.0",
     "@tailosinc/borg-event-stream-kinesis": "^2.12.3",
@@ -38,13 +38,13 @@
     "aws-jwt-verify": "^4.0.1",
     "city-timezones": "1.3.0",
     "didyoumean": "1.2.2",
-    "grafserv": "0.1.1-beta.19",
-    "graphile-build": "5.0.0-beta.29",
-    "graphile-build-pg": "5.0.0-beta.34",
+    "grafserv": "0.1.1-beta.24",
+    "graphile-build": "5.0.0-beta.33",
+    "graphile-build-pg": "5.0.0-beta.38",
     "lodash": "4.17.21",
     "lz-string": "^1.5.0",
-    "postgraphile": "5.0.0-beta.35",
-    "postgraphile-plugin-connection-filter": "3.0.0-beta.7"
+    "postgraphile": "5.0.0-beta.40",
+    "postgraphile-plugin-connection-filter": "3.0.0-beta.8"
   },
   "devDependencies": {
     "@aws-crypto/sha256-js": "^5.2.0",
@@ -59,8 +59,8 @@
     "dotenv": "16.4.1",
     "dotenv-cli": "7.3.0",
     "esbuild-loader": "4.0.3",
-    "graphile": "5.0.0-beta.35",
-    "graphile-export": "0.0.2-beta.22",
+    "graphile": "5.0.0-beta.40",
+    "graphile-export": "0.0.2-beta.26",
     "pg": "^8.13.1",
     "serverless": "^3.40.0",
     "serverless-deployment-bucket": "1.6.0",

While I did not encounter any issues before, I now see the following error output:

> @tailosinc/tycho-operations-api-service@1.0.0 export:schema
> dotenv tsx tools/export-schema.ts

Exporting a GraphQL schema from the database at main...
(node:473212) NOTE: The AWS SDK for JavaScript (v2) is in maintenance mode.
 SDK releases are limited to address critical bug fixes and security issues only.

Please migrate your code to use AWS SDK for JavaScript (v3).
For more information, check the blog post at https://a.co/cUPnyil
(Use `node --trace-warnings ...` to show where the warning was created)
(node:473212) [DEP0091] DeprecationWarning: crypto.DEFAULT_ENCODING is deprecated.
ESLint found problems in the export; this likely indicates some issue with `EXPORTABLE` calls

<text>
  18345:7  error  Parsing error: Unexpected token ;

✖ 1 problem (1 error, 0 warnings)

Which relates to the following code that does not seem to have any syntax issue:

  // For all modes, check null
  if (!false && value === null) {
    throw Object.assign(new Error("Null literals are forbidden in filter argument input."), {
      //TODO: mark this error as safe
    });
  }
}
const PgAggregateConditionExpression = class PgAggregateConditionExpression extends Modifier {
  spec;                           // <--------------------- this is line 18345 referenced above
  pgWhereConditionSpecListToSQL;
  alias;
  conditions = [];
  constructor(parent, spec, pgWhereConditionSpecListToSQL) {
    super(parent);
    this.spec = spec;
    this.pgWhereConditionSpecListToSQL = pgWhereConditionSpecListToSQL;
    this.alias = parent.alias;
  }
  where(condition) {
    this.conditions.push(condition);
  }
  apply() {
    const sqlCondition = this.pgWhereConditionSpecListToSQL(this.alias, this.conditions);
    if (sqlCondition) {
      this.parent.expression(sqlCondition);
    }
  }
};
const PgAggregateCondition = class PgAggregateCondition extends Modifier {
  pgWhereConditionSpecListToSQL;
  sql;
  tableExpression;
  alias;
  conditions = [];
  expressions = [];

Steps to reproduce

Haven't tested this, but effectively:

  1. Install packages from latest release; ensure pg-aggregate is included
  2. Export a schema

Expected results

No errors

Actual results

ESLint found problems in the export; this likely indicates some issue with `EXPORTABLE` calls

<text>
  18345:7  error  Parsing error: Unexpected token ;

✖ 1 problem (1 error, 0 warnings)

Additional context

Here's the definition of EXPORTABLE I'm using:

// NOTE: much better to grab `EXPORTABLE` from the `build` object, but we can't always do that.
export function EXPORTABLE<T, TScope extends any[]>(
  factory: (...args: TScope) => T,
  args: [...TScope],
): T {
  const fn: T = factory(...args);
  if (
    ((typeof fn === 'object' && fn !== null) || typeof fn === 'function')
    && !('$exporter$factory' in fn)
  ) {
    Object.defineProperties(fn, {
      $exporter$args: { value: args },
      $exporter$factory: { value: factory },
    });
  }
  return fn;
}

Possible Solution

🤷‍♂

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions