graphile-contrib/postgraphile-plugin-connection-filter

Broken schema export in v5

nckswt opened this issue · 3 comments

Looks like there was some work done to allow exporting the schema, but I think it missed a function or two. I encountered this error when attempting to export my schema:

/home/nick/code/cloud/tycho-service/packages/operations-metrics/node_modules/graphile-export/dist/exportSchema.js:821
        throw new Error(`The function being exported as ${locationHint} references external variables: \`${[
              ^

Error: The function being exported as StringFilter.fields[isNull].extensions.grafast["applyPlan"][$$scope][2] references external variables: `sql`. Please ensure this function is wrapped in `EXPORTABLE(() => ...)`. Fn:
(i, _v, $input) => sql `${i} ${$input.eval() ? sql `IS NULL` : sql `IS NOT NULL`}`
    at funcToAst (/home/nick/code/cloud/tycho-service/packages/operations-metrics/node_modules/graphile-export/src/exportSchema.ts:1352:11)
    at func (/home/nick/code/cloud/tycho-service/packages/operations-metrics/node_modules/graphile-export/src/exportSchema.ts:1251:12)
    at _convertToAST (/home/nick/code/cloud/tycho-service/packages/operations-metrics/node_modules/graphile-export/src/exportSchema.ts:1028:12)
    at convertToIdentifierViaAST (/home/nick/code/cloud/tycho-service/packages/operations-metrics/node_modules/graphile-export/src/exportSchema.ts:1156:7)
    at <anonymous> (/home/nick/code/cloud/tycho-service/packages/operations-metrics/node_modules/graphile-export/src/exportSchema.ts:1279:12)
    at Array.map (<anonymous>)
    at factoryAst (/home/nick/code/cloud/tycho-service/packages/operations-metrics/node_modules/graphile-export/src/exportSchema.ts:1265:37)
    at convertToIdentifierViaAST (/home/nick/code/cloud/tycho-service/packages/operations-metrics/node_modules/graphile-export/src/exportSchema.ts:1155:7)
    at handleSubvalue (/home/nick/code/cloud/tycho-service/packages/operations-metrics/node_modules/graphile-export/src/exportSchema.ts:983:19)
    at <anonymous> (/home/nick/code/cloud/tycho-service/packages/operations-metrics/node_modules/graphile-export/src/exportSchema.ts:1050:24)
    at Array.forEach (<anonymous>)
    at _convertToAST (/home/nick/code/cloud/tycho-service/packages/operations-metrics/node_modules/graphile-export/src/exportSchema.ts:1048:13)
    at convertToIdentifierViaAST (/home/nick/code/cloud/tycho-service/packages/operations-metrics/node_modules/graphile-export/src/exportSchema.ts:1156:7)
    at <anonymous> (/home/nick/code/cloud/tycho-service/packages/operations-metrics/node_modules/graphile-export/src/exportSchema.ts:1652:13)
    at Array.forEach (<anonymous>)
    at exportSchemaTypeDefs (/home/nick/code/cloud/tycho-service/packages/operations-metrics/node_modules/graphile-export/src/exportSchema.ts:1536:15)
    at exportSchemaAsString (/home/nick/code/cloud/tycho-service/packages/operations-metrics/node_modules/graphile-export/src/exportSchema.ts:1850:5)
    at exportSchema (/home/nick/code/cloud/tycho-service/packages/operations-metrics/node_modules/graphile-export/src/exportSchema.ts:1949:26)
    at main (/home/nick/code/cloud/tycho-service/packages/operations-metrics/tools/export-schema.ts:14:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at <anonymous> (/home/nick/code/cloud/tycho-service/packages/operations-metrics/tools/export-schema.ts:21:1)

Node.js v18.19.0
npm ERR! Lifecycle script `export-schema` failed with error: 
npm ERR! Error: command failed 
npm ERR!   in workspace: @tailosinc/tycho-operations-metrics-service@1.0.0 
npm ERR!   at location: /home/nick/code/cloud/tycho-service/packages/operations-metrics 

Relevant packages from package.json taken from this latest release:

  "dependencies": {
    "grafserv": "0.1.1-beta.8",
    "graphile-build": "5.0.0-beta.16",
    "graphile-build-pg": "5.0.0-beta.20",
    "postgraphile": "5.0.0-beta.21",
    "postgraphile-plugin-connection-filter": "3.0.0-beta.2",
    "@graphile/simplify-inflection": "8.0.0-beta.3"
  },
  "devDependencies": {
    "graphile-export": "0.0.2-beta.11",
    "tsx": "^4.7.0"
  },

This should be fixed in #206, @benjie just did not have had the time to merge it and release it...

Ah, missed that, thanks!

Shipped in postgraphile-plugin-connection-filter@3.0.0-beta.3; sorry for the delay!