graphile-contrib / postgraphile-plugin-connection-filter

Filtering on PostGraphile connections
MIT License
286 stars 32 forks source link

Unable to use root filter variable #163

Closed hboylan closed 1 year ago

hboylan commented 3 years ago

Defining a root-level filter variable causes a stackoverflow error.

Operation:

query AllThings($filter: ThingFilter) {
  allThings(filter: $filter) {
    nodes {
      ...thing
    }
  }
}

fragment thing on Thing {
  id
  name
  createdAt
}

Variables:

{
  "filter": {
    "createdAt": {
      "greaterThanOrEqualTo": "2021-06-18T05:00:00.000Z"
    }
  }
}

Error:

🕸️ =>  ✔ Serving GraphQL Mesh: http://0.0.0.0:4000

<--- Last few GCs --->

[21565:0x104b00000]   183013 ms: Scavenge 4067.6 (4096.2) -> 4060.7 (4095.0) MB, 4.3 / 0.0 ms  (average mu = 0.328, current mu = 0.311) allocation failure 
[21565:0x104b00000]   183033 ms: Scavenge 4070.5 (4099.0) -> 4063.8 (4098.2) MB, 6.6 / 0.0 ms  (average mu = 0.328, current mu = 0.311) allocation failure 
[21565:0x104b00000]   183044 ms: Scavenge 4071.5 (4115.4) -> 4065.5 (4115.7) MB, 2.7 / 0.0 ms  (average mu = 0.328, current mu = 0.311) allocation failure 

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x10130d6e5 node::Abort() (.cold.1) [/usr/local/bin/node]
 2: 0x1000b1c49 node::Abort() [/usr/local/bin/node]
 3: 0x1000b1daf node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 4: 0x1001f60f7 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 5: 0x1001f6093 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 6: 0x1003a54f5 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
 7: 0x1003a6fba v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node]
 8: 0x1003a2689 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
 9: 0x10039ff21 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
10: 0x10039ee98 v8::internal::Heap::HandleGCRequest() [/usr/local/bin/node]
11: 0x10035ae71 v8::internal::StackGuard::HandleInterrupts() [/usr/local/bin/node]
12: 0x1006fb219 v8::internal::Runtime_StackGuard(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
13: 0x100a893d9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/bin/node]
14: 0x100a7c49e Builtins_StringPrototypeTrim [/usr/local/bin/node]
mattbretl commented 3 years ago

Hmmm, I'm not able to repro with this setup:

CREATE SCHEMA app_public;
CREATE TABLE app_public.thing (
    id serial PRIMARY KEY,
    "name" varchar NULL,
    created_at timestamptz NULL
);
INSERT INTO app_public.thing VALUES (1, 'one', now());
const http = require("http");
const { postgraphile } = require("postgraphile");
const ConnectionFilterPlugin = require("postgraphile-plugin-connection-filter");

http
  .createServer(
    postgraphile(
      "postgres:///filter_issue_163",
      "app_public",
      {
        appendPlugins: [ConnectionFilterPlugin],
        graphiql: true,
        enhanceGraphiql: true,
      }
    )
  )
  .listen(process.env.PORT || 3000);

(Same operation and variables that you provided, copied into GraphiQL and executed.)

If you can provide more details on your setup I can give it another shot.

verner3 commented 2 years ago

Hi @hboylan,

We are facing the same issue, did you find a way to fix it ?

Thanks for you help !

mattbretl commented 1 year ago

Closing this as stale, but if anyone is able to provide a simple repro, please reach out! :pray: