Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@ 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:
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/appdb
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
"
4 changes: 4 additions & 0 deletions schema.sql
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
-- Create your database schema here

create table public.test_entity (
id serial primary key
);
34 changes: 34 additions & 0 deletions src/TestPlugin.ts
Original file line number Diff line number Diff line change
@@ -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;
},
},
},
},
},
},
}));
8 changes: 7 additions & 1 deletion src/graphile.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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:
Expand Down