diff --git a/docker-compose.yml b/docker-compose.yml index 38c083b..37b888c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,6 +23,7 @@ services: - ./yarn.lock:/app/yarn.lock - ./.yarn/:/app/.yarn/ - ./.yarnrc.yml:/app/.yarnrc.yml + - ./src:/app/src - ./graphile.config.ts:/app/graphile.config.ts - ./tags.json5:/app/tags.json5 environment: @@ -30,9 +31,5 @@ services: entrypoint: > sh -c " yarn --frozen-lockfile - until pg_isready -h postgres -p 5432 -U postgres; do - echo 'Waiting for Postgres...'; - sleep 1; - done; exec yarn postgraphile -n 0.0.0.0 " diff --git a/schema.sql b/schema.sql index 9fa576e..e59e21c 100644 --- a/schema.sql +++ b/schema.sql @@ -1 +1,5 @@ -- Create your database schema here + +create table public.test_entity ( + id serial primary key +); \ No newline at end of file diff --git a/src/TestPlugin.ts b/src/TestPlugin.ts new file mode 100644 index 0000000..c655fbf --- /dev/null +++ b/src/TestPlugin.ts @@ -0,0 +1,34 @@ +import type { PgSelectStep } from "postgraphile/@dataplan/pg"; +import { extendSchema, gql } from "postgraphile/utils"; + +export const TestPlugin = extendSchema((build) => ({ + typeDefs: gql` + extend type Query { + test(search: String!): [TestEntity]! + } + `, + objects: { + Query: { + plans: { + test: { + plan: (_$root, fieldArgs) => { + const $select = + build.input.pgRegistry.pgResources.test_entity.find(); + console.log("BEFORE_APPLY========================"); + fieldArgs.apply($select); + console.log("AFTER_APPLY========================"); + return $select; + }, + args: { + search: ($root: PgSelectStep, value) => { + console.log("search========================"); + console.log(value); + console.log("search========================"); + return $root; + }, + }, + }, + }, + }, + }, +})); diff --git a/src/graphile.config.ts b/src/graphile.config.ts index a052483..a0a0ba5 100644 --- a/src/graphile.config.ts +++ b/src/graphile.config.ts @@ -12,6 +12,7 @@ import PersistedPlugin from "@grafserv/persisted"; import { PgOmitArchivedPlugin } from "@graphile-contrib/pg-omit-archived"; import { dirname } from "path"; import { fileURLToPath } from "url"; +import { TestPlugin } from "./TestPlugin.ts"; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); @@ -33,7 +34,12 @@ const preset: GraphileConfig.Preset = { PgAggregatesPreset, // PgSimplifyInflectionPreset ], - plugins: [PersistedPlugin.default, PgOmitArchivedPlugin, TagsFilePlugin], + plugins: [ + PersistedPlugin.default, + PgOmitArchivedPlugin, + TagsFilePlugin, + TestPlugin, + ], pgServices: [ makePgService({ // Database connection string: