From 3271f57eef98af526b751571ffc4fbf5e2d660ae Mon Sep 17 00:00:00 2001 From: Achintha Weerasinghe Date: Thu, 9 Jan 2025 14:03:55 +0530 Subject: [PATCH 01/11] custom re-prod --- .vscode/settings.json | 3 ++ graphile.config.mjs | 11 +++++- package.json | 1 + plugins.mjs | 91 +++++++++++++++++++++++++++++++++++++++++++ schema.sql | 18 +++++++++ yarn.lock | 28 +++++++++++++ 6 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 .vscode/settings.json create mode 100644 plugins.mjs create mode 100644 schema.sql diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..55712c1 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "typescript.tsdk": "node_modules/typescript/lib" +} \ No newline at end of file diff --git a/graphile.config.mjs b/graphile.config.mjs index 0166d12..e313115 100644 --- a/graphile.config.mjs +++ b/graphile.config.mjs @@ -11,10 +11,14 @@ import PersistedPlugin from "@grafserv/persisted"; import { PgOmitArchivedPlugin } from "@graphile-contrib/pg-omit-archived"; import { dirname } from "path"; import { fileURLToPath } from "url"; +import { myExtensions } from "./plugins.mjs"; +import pg from 'pg' const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); +const { Pool } = pg; + // For configuration file details, see: https://postgraphile.org/postgraphile/next/config const TagsFilePlugin = makePgSmartTagsFromFilePlugin(`${__dirname}/tags.json5`); @@ -33,7 +37,7 @@ const preset = { PgAggregatesPreset, // PgSimplifyInflectionPreset ], - plugins: [PersistedPlugin.default, PgOmitArchivedPlugin, TagsFilePlugin], + plugins: [PersistedPlugin.default, PgOmitArchivedPlugin, TagsFilePlugin, myExtensions], pgServices: [ makePgService({ // Database connection string: @@ -54,6 +58,11 @@ const preset = { }, grafast: { explain: true, + context: (ctx, args) => ({ + pool: new Pool({ + connectionString: process.env.DATABASE_URL + }) + }) }, }; diff --git a/package.json b/package.json index e1a45eb..f5262d3 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@graphile/simplify-inflection": "^8.0.0-beta.5", "express": "^4.18.2", "graphile": "^5.0.0-beta.36", + "pg": "^8.13.1", "postgraphile": "^5.0.0-beta.36", "postgraphile-plugin-connection-filter": "^3.0.0-beta.7", "ws": "^8.13.0" diff --git a/plugins.mjs b/plugins.mjs new file mode 100644 index 0000000..0b8a4d7 --- /dev/null +++ b/plugins.mjs @@ -0,0 +1,91 @@ +import { pgPolymorphic, withPgClient } from "postgraphile/@dataplan/pg"; +import { gql, makeExtendSchemaPlugin } from "postgraphile/utils"; + +export const myExtensions = makeExtendSchemaPlugin((build) => { + const { + input: { + pgRegistry: { + pgResources: { cat, dog }, + }, + }, + grafast: { access, each, object, constant, loadMany, context }, + } = build; + + return { + typeDefs: gql` + input AnimalIdsAndTypesInput { + id: String! + type: String! + } + union Animal = Dog | Cat + + extend type Query { + animals(input: [AnimalIdsAndTypesInput!]!): [Animal]! + } + + extend type Cat { + canSpeak: JSON + } + `, + plans: { + Query: { + animals(_, fieldArgs) { + const entityMap = { + Cat: { + match: (specifier) => specifier.type === "CAT", + plan: ($specifier) => cat.get({ id: access($specifier, ["id"]) }), + }, + Dog: { + match: (specifier) => specifier.type === "DOG", + plan: ($specifier) => dog.get({ id: access($specifier, ["id"]) }), + }, + }; + + return each(fieldArgs.get("input"), ($content) => { + const $specifier = object({ + id: access($content, ["id"]), + type: access($content, ["type"]), + }); + return pgPolymorphic($content, $specifier, entityMap); + }); + }, + }, + Cat: { + canSpeak() { + // const $settings = withPgClient( + // cat.executor, + // constant(null), + // async (client) => { + // const { rows } = await client.query({ + // text: /* SQL */ ` + // SELECT id + // FROM public.cat + // `, + // }); + + // return rows; + // } + // ); + const $settings = loadMany(constant(null), context().get('pool'), batchGetDogs); + + return $settings; + }, + }, + }, + }; +}); + +async function batchGetDogs(data, { unary: dbClient }) { + if (data.length === 0) { + return []; + } + + const result = await dbClient.query({ + text: /* SQL */ ` + SELECT id + FROM public.dog + `, + }); + + return data.map(() => result.rows); +} diff --git a/schema.sql b/schema.sql new file mode 100644 index 0000000..2777b77 --- /dev/null +++ b/schema.sql @@ -0,0 +1,18 @@ +drop table if exists public.cat; +create table public.cat( + id serial primary key, + name text +); + +drop table if exists public.dog; +create table public.dog( + id serial primary key, + name text, + owner_name text +); + +insert into public.cat (name) +values('Niki'), ('Milo'); + +insert into public.dog (name, owner_name) +values ('Bruno', 'Andrey'), ('Ghost', 'Achintha'); \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 90dfe7c..549ddf6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -870,6 +870,11 @@ pg-connection-string@^2.6.2: resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.6.2.tgz#713d82053de4e2bd166fab70cd4f26ad36aab475" integrity sha512-ch6OwaeaPYcova4kKZ15sbJ2hKb/VP48ZD2gE7i1J+L4MspCtBMAx8nMgz7bksc7IojCIIWuEhHibSMFH8m8oA== +pg-connection-string@^2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.7.0.tgz#f1d3489e427c62ece022dba98d5262efcb168b37" + integrity sha512-PI2W9mv53rXJQEOb8xNR8lH7Hr+EKa6oJa38zsK0S/ky2er16ios1wLKhZyxzD7jUReiWokc9WK5nxSnC7W1TA== + pg-int8@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/pg-int8/-/pg-int8-1.0.1.tgz#943bd463bf5b71b4170115f80f8efc9a0c0eb78c" @@ -892,11 +897,21 @@ pg-pool@^3.6.1: resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-3.6.1.tgz#5a902eda79a8d7e3c928b77abf776b3cb7d351f7" integrity sha512-jizsIzhkIitxCGfPRzJn1ZdcosIt3pz9Sh3V01fm1vZnbnCMgmGl5wvGGdNN2EL9Rmb0EcFoCkixH4Pu+sP9Og== +pg-pool@^3.7.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-3.7.0.tgz#d4d3c7ad640f8c6a2245adc369bafde4ebb8cbec" + integrity sha512-ZOBQForurqh4zZWjrgSwwAtzJ7QiRX0ovFkZr2klsen3Nm0aoh33Ls0fzfv3imeH/nw/O27cjdz5kzYJfeGp/g== + pg-protocol@*, pg-protocol@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.6.0.tgz#4c91613c0315349363af2084608db843502f8833" integrity sha512-M+PDm637OY5WM307051+bsDia5Xej6d9IR4GwJse1qA1DIhiKlksvrneZOYQq42OM+spubpcNYEo2FcKQrDk+Q== +pg-protocol@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.7.0.tgz#ec037c87c20515372692edac8b63cf4405448a93" + integrity sha512-hTK/mE36i8fDDhgDFjy6xNOG+LCorxLG3WO17tku+ij6sVHXh1jQUJ8hYAnRhNla4QVD2H8er/FOjc/+EgC6yQ== + pg-sql2@^5.0.0-beta.7: version "5.0.0-beta.7" resolved "https://registry.yarnpkg.com/pg-sql2/-/pg-sql2-5.0.0-beta.7.tgz#2815ae66be75bb844d3db49feae9009c3552655e" @@ -944,6 +959,19 @@ pg@^8.11.3: optionalDependencies: pg-cloudflare "^1.1.1" +pg@^8.13.1: + version "8.13.1" + resolved "https://registry.yarnpkg.com/pg/-/pg-8.13.1.tgz#6498d8b0a87ff76c2df7a32160309d3168c0c080" + integrity sha512-OUir1A0rPNZlX//c7ksiu7crsGZTKSOXJPgtNiHGIlC9H0lO+NC6ZDYksSgBYY/thSWhnSRBv8w1lieNNGATNQ== + dependencies: + pg-connection-string "^2.7.0" + pg-pool "^3.7.0" + pg-protocol "^1.7.0" + pg-types "^2.1.0" + pgpass "1.x" + optionalDependencies: + pg-cloudflare "^1.1.1" + pgpass@1.x: version "1.0.5" resolved "https://registry.yarnpkg.com/pgpass/-/pgpass-1.0.5.tgz#9b873e4a564bb10fa7a7dbd55312728d422a223d" From 40b9ea5cc84bbd36108d5161fc521137a5f6b83a Mon Sep 17 00:00:00 2001 From: Achintha Weerasinghe Date: Thu, 9 Jan 2025 16:27:42 +0530 Subject: [PATCH 02/11] plugin updated --- plugins.mjs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins.mjs b/plugins.mjs index 0b8a4d7..1e613aa 100644 --- a/plugins.mjs +++ b/plugins.mjs @@ -24,7 +24,7 @@ export const myExtensions = makeExtendSchemaPlugin((build) => { } extend type Cat { - canSpeak: JSON + enemies: JSON } `, plans: { @@ -51,21 +51,21 @@ export const myExtensions = makeExtendSchemaPlugin((build) => { }, }, Cat: { - canSpeak() { - // const $settings = withPgClient( - // cat.executor, - // constant(null), - // async (client) => { - // const { rows } = await client.query({ - // text: /* SQL */ ` - // SELECT id - // FROM public.cat - // `, - // }); + enemies() { + // const $settings = withPgClient( + // cat.executor, + // constant(null), + // async (client) => { + // const { rows } = await client.query({ + // text: /* SQL */ ` + // SELECT id + // FROM public.cat + // `, + // }); - // return rows; - // } - // ); + // return rows; + // } + // ); const $settings = loadMany(constant(null), context().get('pool'), batchGetDogs); return $settings; From 9e4660e15c3d5c1342cfeabc0996fe54a0f02a81 Mon Sep 17 00:00:00 2001 From: Achintha Weerasinghe Date: Fri, 4 Apr 2025 15:04:02 +0530 Subject: [PATCH 03/11] temp --- plugins.mjs | 103 +++++++++++++++++++++------------------------------- schema.sql | 57 +++++++++++++++++++++++------ 2 files changed, 87 insertions(+), 73 deletions(-) diff --git a/plugins.mjs b/plugins.mjs index 1e613aa..35a2533 100644 --- a/plugins.mjs +++ b/plugins.mjs @@ -5,87 +5,66 @@ export const myExtensions = makeExtendSchemaPlugin((build) => { const { input: { pgRegistry: { - pgResources: { cat, dog }, + pgResources: { animal, shop, owner }, }, }, - grafast: { access, each, object, constant, loadMany, context }, + grafast: { access, each, object, constant, loadMany, context, connection }, } = build; return { typeDefs: gql` - input AnimalIdsAndTypesInput { - id: String! - type: String! + extend type Shop { + animals: AnimalsConnection } - union Animal = Dog | Cat - extend type Query { - animals(input: [AnimalIdsAndTypesInput!]!): [Animal]! + extend type CatAnimal { + owners: OwnersConnection + } + extend type DogAnimal { + owners: OwnersConnection } - extend type Cat { - enemies: JSON + extend type Owner { + hasClinic: Boolean } `, plans: { - Query: { - animals(_, fieldArgs) { - const entityMap = { - Cat: { - match: (specifier) => specifier.type === "CAT", - plan: ($specifier) => cat.get({ id: access($specifier, ["id"]) }), - }, - Dog: { - match: (specifier) => specifier.type === "DOG", - plan: ($specifier) => dog.get({ id: access($specifier, ["id"]) }), - }, - }; + Shop: { + animals($shop) { + const $animals = animal.find({ + shop_id: $shop.get('id') + }) - return each(fieldArgs.get("input"), ($content) => { - const $specifier = object({ - id: access($content, ["id"]), - type: access($content, ["type"]), - }); - return pgPolymorphic($content, $specifier, entityMap); - }); + return connection($animals) }, }, - Cat: { - enemies() { - // const $settings = withPgClient( - // cat.executor, - // constant(null), - // async (client) => { - // const { rows } = await client.query({ - // text: /* SQL */ ` - // SELECT id - // FROM public.cat - // `, - // }); + CatAnimal: { + owners($animal) { + const $food = owner.find({ + animal_id: $animal.get('id') + }) - // return rows; - // } - // ); - const $settings = loadMany(constant(null), context().get('pool'), batchGetDogs); + return connection($food) + } + }, + DogAnimal: { + owners($animal) { + const $food = owner.find({ + animal_id: $animal.get('id') + }) - return $settings; - }, + return connection($food) + } }, + Owner: { + hasClinic($owner) { + const $shop = shop.get({ + id: $owner.get('owner_id') + }) + + return $shop.get('has_clinic') + } + } }, }; }); - -async function batchGetDogs(data, { unary: dbClient }) { - if (data.length === 0) { - return []; - } - - const result = await dbClient.query({ - text: /* SQL */ ` - SELECT id - FROM public.dog - `, - }); - - return data.map(() => result.rows); -} diff --git a/schema.sql b/schema.sql index 2777b77..263e27a 100644 --- a/schema.sql +++ b/schema.sql @@ -1,18 +1,53 @@ -drop table if exists public.cat; -create table public.cat( +-- drop table if exists public.cat; +-- create table public.cat( +-- id serial primary key, +-- name text not null +-- ); + +-- drop table if exists public.dog; +-- create table public.dog( +-- id serial primary key, +-- name text not null, +-- owner_name text +-- ); + +-- insert into public.cat (name) +-- values('Niki'), ('Milo'); + +-- insert into public.dog (name, owner_name) +-- values ('Bruno', 'Andrey'), ('Ghost', 'Achintha'); + +drop table if exists public.shop; +create table public.shop( id serial primary key, - name text + name text, + type text not null, + has_clinic boolean ); +insert into public.shop (name, type, has_clinic) +values('Super Axinom', 'super', true), ('Local Keells', 'local', false); -drop table if exists public.dog; -create table public.dog( +drop table if exists public.animal; +create table public.animal( id serial primary key, name text, - owner_name text + type text not null, + shop_id integer not null ); +comment on table public.animal is $$ + @interface mode:single type:type + @type cat name:CatAnimal + @type dog name:DogAnimal +$$; +insert into public.animal (name, type, shop_id) +values('Niki', 'dog', 1), ('Milo', 'cat', 2); -insert into public.cat (name) -values('Niki'), ('Milo'); - -insert into public.dog (name, owner_name) -values ('Bruno', 'Andrey'), ('Ghost', 'Achintha'); \ No newline at end of file +drop table if exists public.owner; +create table public.owner( + id serial primary key, + animal_id integer not null, + owner_type text not null, + owner_id integer not null +); +insert into public.owner (animal_id, owner_type, owner_id) +values(1, 'person', 5), (2, 'shop', 6); \ No newline at end of file From 0055cae83bd82644eb5fdf186713317d1e27ad78 Mon Sep 17 00:00:00 2001 From: Achintha Weerasinghe Date: Mon, 7 Apr 2025 12:08:56 +0530 Subject: [PATCH 04/11] plugin updated --- plugins.mjs | 36 +++++++++++++++++++++++++++--------- schema.sql | 19 ------------------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/plugins.mjs b/plugins.mjs index 35a2533..5616e85 100644 --- a/plugins.mjs +++ b/plugins.mjs @@ -1,4 +1,6 @@ -import { pgPolymorphic, withPgClient } from "postgraphile/@dataplan/pg"; + +import { sideEffect } from "postgraphile/grafast"; +import { GraphQLError } from "postgraphile/graphql"; import { gql, makeExtendSchemaPlugin } from "postgraphile/utils"; export const myExtensions = makeExtendSchemaPlugin((build) => { @@ -8,7 +10,7 @@ export const myExtensions = makeExtendSchemaPlugin((build) => { pgResources: { animal, shop, owner }, }, }, - grafast: { access, each, object, constant, loadMany, context, connection }, + grafast: { connection }, } = build; return { @@ -30,7 +32,12 @@ export const myExtensions = makeExtendSchemaPlugin((build) => { `, plans: { Shop: { - animals($shop) { + animals($shop, { $first }) { + sideEffect($first, (arg) => { + if (arg && arg > 10) { + throw new GraphQLError('wrong input') + } + }) const $animals = animal.find({ shop_id: $shop.get('id') }) @@ -39,21 +46,31 @@ export const myExtensions = makeExtendSchemaPlugin((build) => { }, }, CatAnimal: { - owners($animal) { - const $food = owner.find({ + owners($animal, { $first }) { + sideEffect($first, (arg) => { + if (arg && arg > 10) { + throw new GraphQLError('wrong input') + } + }) + const $owners = owner.find({ animal_id: $animal.get('id') }) - return connection($food) + return connection($owners); } }, DogAnimal: { - owners($animal) { - const $food = owner.find({ + owners($animal, { $first }) { + sideEffect($first, (arg) => { + if (arg && arg > 10) { + throw new GraphQLError('wrong input') + } + }) + const $owners = owner.find({ animal_id: $animal.get('id') }) - return connection($food) + return connection($owners); } }, Owner: { @@ -68,3 +85,4 @@ export const myExtensions = makeExtendSchemaPlugin((build) => { }, }; }); + diff --git a/schema.sql b/schema.sql index 263e27a..3f61da3 100644 --- a/schema.sql +++ b/schema.sql @@ -1,22 +1,3 @@ --- drop table if exists public.cat; --- create table public.cat( --- id serial primary key, --- name text not null --- ); - --- drop table if exists public.dog; --- create table public.dog( --- id serial primary key, --- name text not null, --- owner_name text --- ); - --- insert into public.cat (name) --- values('Niki'), ('Milo'); - --- insert into public.dog (name, owner_name) --- values ('Bruno', 'Andrey'), ('Ghost', 'Achintha'); - drop table if exists public.shop; create table public.shop( id serial primary key, From 019f0f709873507f410429eaa8a7180aa7066ae7 Mon Sep 17 00:00:00 2001 From: Achintha Weerasinghe Date: Mon, 7 Apr 2025 13:23:50 +0530 Subject: [PATCH 05/11] vs code removed --- .vscode/settings.json | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 55712c1..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "typescript.tsdk": "node_modules/typescript/lib" -} \ No newline at end of file From a477dc8af14253beeebd8590039d8708b7ec1593 Mon Sep 17 00:00:00 2001 From: Achintha Weerasinghe Date: Mon, 7 Apr 2025 13:24:40 +0530 Subject: [PATCH 06/11] pg removed --- package.json | 1 - yarn.lock | 23 ----------------------- 2 files changed, 24 deletions(-) diff --git a/package.json b/package.json index 99d9d70..931b019 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "@graphile/simplify-inflection": "^8.0.0-beta.6", "express": "^4.18.2", "graphile": "^5.0.0-beta.40", - "pg": "^8.13.1", "postgraphile": "^5.0.0-beta.40", "postgraphile-plugin-connection-filter": "^3.0.0-beta.8", "ws": "^8.13.0" diff --git a/yarn.lock b/yarn.lock index cf98f85..b4c0fa3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -877,11 +877,6 @@ pg-numeric@1.0.2: resolved "https://registry.yarnpkg.com/pg-numeric/-/pg-numeric-1.0.2.tgz#816d9a44026086ae8ae74839acd6a09b0636aa3a" integrity sha512-BM/Thnrw5jm2kKLE5uJkXqqExRUY/toLHda65XgFTBTFYZyopbKjBe29Ii3RbkvlsMoFwD+tHeGaCjjv0gHlyw== -pg-pool@^3.7.0: - version "3.7.0" - resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-3.7.0.tgz#d4d3c7ad640f8c6a2245adc369bafde4ebb8cbec" - integrity sha512-ZOBQForurqh4zZWjrgSwwAtzJ7QiRX0ovFkZr2klsen3Nm0aoh33Ls0fzfv3imeH/nw/O27cjdz5kzYJfeGp/g== - pg-pool@^3.8.0: version "3.8.0" resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-3.8.0.tgz#e6bce7fc4506a8d6106551363fc5283e5445b776" @@ -892,11 +887,6 @@ pg-protocol@*: resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.6.0.tgz#4c91613c0315349363af2084608db843502f8833" integrity sha512-M+PDm637OY5WM307051+bsDia5Xej6d9IR4GwJse1qA1DIhiKlksvrneZOYQq42OM+spubpcNYEo2FcKQrDk+Q== -pg-protocol@^1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.7.0.tgz#ec037c87c20515372692edac8b63cf4405448a93" - integrity sha512-hTK/mE36i8fDDhgDFjy6xNOG+LCorxLG3WO17tku+ij6sVHXh1jQUJ8hYAnRhNla4QVD2H8er/FOjc/+EgC6yQ== - pg-protocol@^1.8.0: version "1.8.0" resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.8.0.tgz#c707101dd07813868035a44571488e4b98639d48" @@ -934,19 +924,6 @@ pg-types@^4.0.1: postgres-interval "^3.0.0" postgres-range "^1.1.1" -pg@^8.13.1: - version "8.13.1" - resolved "https://registry.yarnpkg.com/pg/-/pg-8.13.1.tgz#6498d8b0a87ff76c2df7a32160309d3168c0c080" - integrity sha512-OUir1A0rPNZlX//c7ksiu7crsGZTKSOXJPgtNiHGIlC9H0lO+NC6ZDYksSgBYY/thSWhnSRBv8w1lieNNGATNQ== - dependencies: - pg-connection-string "^2.7.0" - pg-pool "^3.7.0" - pg-protocol "^1.7.0" - pg-types "^2.1.0" - pgpass "1.x" - optionalDependencies: - pg-cloudflare "^1.1.1" - pg@^8.13.3: version "8.14.1" resolved "https://registry.yarnpkg.com/pg/-/pg-8.14.1.tgz#2e3d1f287b64797cdfc8d1ba000f61a7ff8d66ed" From 0ae160370f203e4bea8bb87b53c8bf478311b06d Mon Sep 17 00:00:00 2001 From: Achintha Weerasinghe Date: Mon, 7 Apr 2025 13:26:01 +0530 Subject: [PATCH 07/11] config update --- graphile.config.mjs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/graphile.config.mjs b/graphile.config.mjs index e313115..0da3b76 100644 --- a/graphile.config.mjs +++ b/graphile.config.mjs @@ -12,13 +12,10 @@ import { PgOmitArchivedPlugin } from "@graphile-contrib/pg-omit-archived"; import { dirname } from "path"; import { fileURLToPath } from "url"; import { myExtensions } from "./plugins.mjs"; -import pg from 'pg' const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); -const { Pool } = pg; - // For configuration file details, see: https://postgraphile.org/postgraphile/next/config const TagsFilePlugin = makePgSmartTagsFromFilePlugin(`${__dirname}/tags.json5`); @@ -58,11 +55,6 @@ const preset = { }, grafast: { explain: true, - context: (ctx, args) => ({ - pool: new Pool({ - connectionString: process.env.DATABASE_URL - }) - }) }, }; From f9d9cd0ed233689703c6c15e9c158d99af24ed3b Mon Sep 17 00:00:00 2001 From: Achintha Weerasinghe Date: Thu, 17 Apr 2025 12:01:07 +0530 Subject: [PATCH 08/11] issue recreate --- graphile.config.mjs | 1 + plugins.mjs | 94 +++++++++++++++++++-------------------------- schema.sql | 62 ++++++++++++++++++------------ 3 files changed, 78 insertions(+), 79 deletions(-) diff --git a/graphile.config.mjs b/graphile.config.mjs index 0da3b76..b476652 100644 --- a/graphile.config.mjs +++ b/graphile.config.mjs @@ -26,6 +26,7 @@ const preset = { AmberPreset.default ?? AmberPreset, makeV4Preset({ /* Enter your V4 options here */ + dynamicJson: true, graphiql: true, graphiqlRoute: "/", }), diff --git a/plugins.mjs b/plugins.mjs index 5616e85..e799768 100644 --- a/plugins.mjs +++ b/plugins.mjs @@ -1,85 +1,69 @@ - -import { sideEffect } from "postgraphile/grafast"; -import { GraphQLError } from "postgraphile/graphql"; +import { TYPES } from 'postgraphile/@dataplan/pg'; import { gql, makeExtendSchemaPlugin } from "postgraphile/utils"; export const myExtensions = makeExtendSchemaPlugin((build) => { const { input: { pgRegistry: { - pgResources: { animal, shop, owner }, + pgResources: { shop, pet, get_shop_info }, }, }, - grafast: { connection }, + grafast: { each, constant, lambda, connection }, } = build; return { typeDefs: gql` - extend type Shop { - animals: AnimalsConnection + extend type Query { + shopsByIds(ids: [Int!]!): [Shop]! } - extend type CatAnimal { - owners: OwnersConnection + extend type Shop { + info: ShopInfo + pets: PetsConnection } - extend type DogAnimal { - owners: OwnersConnection + + type ShopInfo { + petInfo(filter: String): JSON + customersInfo(filter: String): JSON } - extend type Owner { - hasClinic: Boolean + extend type Pet { + shop: Shop } `, plans: { + Query: { + shopsByIds(_, { $ids }) { + return each($ids, ($id) => shop.find({ id: $id, visible: constant(true) }).single()) + } + }, Shop: { - animals($shop, { $first }) { - sideEffect($first, (arg) => { - if (arg && arg > 10) { - throw new GraphQLError('wrong input') - } - }) - const $animals = animal.find({ - shop_id: $shop.get('id') - }) - - return connection($animals) + info($parent) { + return $parent; }, - }, - CatAnimal: { - owners($animal, { $first }) { - sideEffect($first, (arg) => { - if (arg && arg > 10) { - throw new GraphQLError('wrong input') - } - }) - const $owners = owner.find({ - animal_id: $animal.get('id') - }) - - return connection($owners); + pets($parent) { + return connection(pet.find({ shop_id: $parent.get('id') })) } }, - DogAnimal: { - owners($animal, { $first }) { - sideEffect($first, (arg) => { - if (arg && arg > 10) { - throw new GraphQLError('wrong input') - } - }) - const $owners = owner.find({ - animal_id: $animal.get('id') - }) + ShopInfo: { + petInfo($parent, { $filter }) { + const $fnData = get_shop_info.execute([{ step: $parent.get('id'), pgCodec: TYPES.int, name: 'id_param' }], 'normal') - return connection($owners); + return lambda([$fnData, $filter], ([fnData, filter]) => { + return { pet: fnData, filter } + }); + }, + customersInfo($parent, { $filter }) { + const $fnData = get_shop_info.execute([{ step: $parent.get('id'), pgCodec: TYPES.int, name: 'id_param' }], 'normal') + + return lambda([$fnData, $filter], ([fnData, filter]) => { + return { customer: fnData, filter } + }); } }, - Owner: { - hasClinic($owner) { - const $shop = shop.get({ - id: $owner.get('owner_id') - }) - - return $shop.get('has_clinic') + Pet: { + shop($parent) { + return shop.get({ id: $parent.get('shop_id') }); } } }, diff --git a/schema.sql b/schema.sql index 3f61da3..0569f80 100644 --- a/schema.sql +++ b/schema.sql @@ -2,33 +2,47 @@ drop table if exists public.shop; create table public.shop( id serial primary key, name text, - type text not null, - has_clinic boolean + visible boolean ); -insert into public.shop (name, type, has_clinic) -values('Super Axinom', 'super', true), ('Local Keells', 'local', false); -drop table if exists public.animal; -create table public.animal( +INSERT INTO public.shop (name, visible) +SELECT + substr(md5(random()::text), 1, 10), + random() < 0.5 +FROM generate_series(1, 50000); + +drop table if exists public.pet; +create table public.pet( id serial primary key, name text, - type text not null, - shop_id integer not null + type text, + shop_id integer ); -comment on table public.animal is $$ - @interface mode:single type:type - @type cat name:CatAnimal - @type dog name:DogAnimal -$$; -insert into public.animal (name, type, shop_id) -values('Niki', 'dog', 1), ('Milo', 'cat', 2); -drop table if exists public.owner; -create table public.owner( - id serial primary key, - animal_id integer not null, - owner_type text not null, - owner_id integer not null -); -insert into public.owner (animal_id, owner_type, owner_id) -values(1, 'person', 5), (2, 'shop', 6); \ No newline at end of file +INSERT INTO public.pet (name, type, shop_id) +SELECT + substr(md5(random()::text), 1, 10) AS name, + (ARRAY['cat', 'dog', 'parrot', 'rabbit'])[floor(random() * 4 + 1)::int] AS type, + floor(random() * 50000 + 1)::int AS shop_id +FROM generate_series(1, 50000); + +CREATE OR REPLACE FUNCTION public.get_shop_info(id_param integer) +RETURNS json AS $$ +DECLARE + result_row json; +BEGIN + SELECT json_build_object( + 'assetId', s.id, + 'petId', p.id, + 'petType', p.type, + 'text', s.name || ' - ' || p.name + ) + INTO result_row + FROM public.shop s + LEFT JOIN public.pet p + ON s.id = p.shop_id + WHERE s.id = id_param; + + RETURN result_row; +END; +$$ LANGUAGE plpgsql STABLE; From 00c144a012bcc866bc13638058c2b2f0baceb468 Mon Sep 17 00:00:00 2001 From: Achintha Weerasinghe Date: Thu, 17 Apr 2025 19:28:32 +0530 Subject: [PATCH 09/11] issue recreated --- graphile.config.mjs | 3 +- package.json | 1 + plugins.mjs | 55 ++++++++++---- schema.sql | 178 ++++++++++++++++++++++++++++++++++++++++---- yarn.lock | 10 ++- 5 files changed, 213 insertions(+), 34 deletions(-) diff --git a/graphile.config.mjs b/graphile.config.mjs index b476652..cc54bc1 100644 --- a/graphile.config.mjs +++ b/graphile.config.mjs @@ -12,6 +12,7 @@ import { PgOmitArchivedPlugin } from "@graphile-contrib/pg-omit-archived"; import { dirname } from "path"; import { fileURLToPath } from "url"; import { myExtensions } from "./plugins.mjs"; +import { createPgGroupedAttributesPlugin } from "@axinom/pg-grouped-attributes-plugin"; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); @@ -35,7 +36,7 @@ const preset = { PgAggregatesPreset, // PgSimplifyInflectionPreset ], - plugins: [PersistedPlugin.default, PgOmitArchivedPlugin, TagsFilePlugin, myExtensions], + plugins: [PersistedPlugin.default, PgOmitArchivedPlugin, TagsFilePlugin, createPgGroupedAttributesPlugin({ separator: '__' }), myExtensions], pgServices: [ makePgService({ // Database connection string: diff --git a/package.json b/package.json index 931b019..65a3314 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "postgraphile": "postgraphile" }, "dependencies": { + "@axinom/pg-grouped-attributes-plugin": "^0.0.2-beta.15", "@grafserv/persisted": "^0.0.0-beta.34", "@graphile-contrib/pg-many-to-many": "^2.0.0-beta.7", "@graphile-contrib/pg-omit-archived": "^4.0.0-beta.4", diff --git a/plugins.mjs b/plugins.mjs index e799768..90f3810 100644 --- a/plugins.mjs +++ b/plugins.mjs @@ -5,10 +5,10 @@ export const myExtensions = makeExtendSchemaPlugin((build) => { const { input: { pgRegistry: { - pgResources: { shop, pet, get_shop_info }, + pgResources: { shop, owner, v_metadata, image, get_shop_info }, }, }, - grafast: { each, constant, lambda, connection }, + grafast: { each, constant, lambda, connection, object }, } = build; return { @@ -19,7 +19,8 @@ export const myExtensions = makeExtendSchemaPlugin((build) => { extend type Shop { info: ShopInfo - pets: PetsConnection + owner: Owner + options: MetaOptions } type ShopInfo { @@ -27,8 +28,14 @@ export const myExtensions = makeExtendSchemaPlugin((build) => { customersInfo(filter: String): JSON } - extend type Pet { - shop: Shop + type MetaOptions { + pickup: Boolean! + worldwide: Boolean! + random: String + } + + extend type ShopFrontImage { + layouts: Image } `, plans: { @@ -41,29 +48,45 @@ export const myExtensions = makeExtendSchemaPlugin((build) => { info($parent) { return $parent; }, - pets($parent) { - return connection(pet.find({ shop_id: $parent.get('id') })) + owner($parent) { + return owner + .find({ + id: $parent.get('owner_id'), + }) + .single(); + }, + options($parent) { + const special = v_metadata.find({ + id: $parent.get('dis_special'), + }); + const specialTitle = special.single().get('title'); + return object({ + pickup: lambda($parent.get('di_pickup'), (v) => v !== null), + worldwide: lambda($parent.get('di_worldwide'), (v) => v !== null), + random: specialTitle, + }); } }, ShopInfo: { petInfo($parent, { $filter }) { const $fnData = get_shop_info.execute([{ step: $parent.get('id'), pgCodec: TYPES.int, name: 'id_param' }], 'normal') - return lambda([$fnData, $filter], ([fnData, filter]) => { - return { pet: fnData, filter } - }); + return $fnData; }, customersInfo($parent, { $filter }) { const $fnData = get_shop_info.execute([{ step: $parent.get('id'), pgCodec: TYPES.int, name: 'id_param' }], 'normal') - return lambda([$fnData, $filter], ([fnData, filter]) => { - return { customer: fnData, filter } - }); + return $fnData; } }, - Pet: { - shop($parent) { - return shop.get({ id: $parent.get('shop_id') }); + ShopFrontImage: { + layouts($parent) { + const $layouts = image.find({ + parent_id: $parent.get('id'), + parent_type: 'shop', + type: 'front', + }); + return $layouts.single(); } } }, diff --git a/schema.sql b/schema.sql index 0569f80..bcb257c 100644 --- a/schema.sql +++ b/schema.sql @@ -1,32 +1,178 @@ +drop table if exists public.owner; +create table public.owner( + id text, + name text +); +insert into public.owner (id, name) +values ('1', 'Andrey'), ('2', 'Kaarel'); + drop table if exists public.shop; create table public.shop( - id serial primary key, + id text, name text, - visible boolean + visible boolean, + owner_id text, + di_pickup text, + di_worldwide text, + dis_special text, + front__title text, + front__description text, + front__image__title text, + front__image__caption text, + front__image__alt_text text ); - -INSERT INTO public.shop (name, visible) -SELECT - substr(md5(random()::text), 1, 10), - random() < 0.5 -FROM generate_series(1, 50000); +INSERT INTO public.shop ( + id, + name, + visible, + owner_id, + di_pickup, + di_worldwide, + dis_special, + front__title, + front__description, + front__image__title, + front__image__caption, + front__image__alt_text +) VALUES ( + '1', + 'One', + true, + '1', + '1', + '2', + '3', + 'Front title', + 'Front Description', + 'Front image title', + 'Front image caption', + 'Front image alt text' +), +( + '2', + 'Two', + true, + '2', + '1', + '2', + '3', + 'Front title', + 'Front Description', + 'Front image title', + 'Front image caption', + 'Front image alt text' +), +( + '3', + 'Three', + true, + '1', + '1', + '2', + '3', + 'Front title', + 'Front Description', + 'Front image title', + 'Front image caption', + 'Front image alt text' +), +( + '4', + 'Four', + true, + '2', + '1', + '2', + '3', + 'Front title', + 'Front Description', + 'Front image title', + 'Front image caption', + 'Front image alt text' +); +comment on table public.shop is $$ + @group front +$$; drop table if exists public.pet; create table public.pet( - id serial primary key, + id text, name text, type text, - shop_id integer + shop_id text +); +insert into public.pet (id, name, type, shop_id) +values ('1', 'Nikki', 'cat', '1'), + ('2', 'Brown', 'dog', '2'); + +drop view if exists public.v_metadata; + +drop table if exists public.metadata; +create table public.metadata( + id text, + type text, + title text ); +INSERT INTO public.metadata (id, type, title) +VALUES ('1', 'pickup', '10% off on all pickups'), + ('2', 'donate', 'We accept your valuable donations via cards'), + ('3', 'worldwide', 'We delivery anywhere with care'); -INSERT INTO public.pet (name, type, shop_id) +drop table if exists public.metadata_enriched; +create table public.metadata_enriched( + id text, + type text, + title text, + enriched_text text +); +INSERT INTO public.metadata_enriched (id, type, title, enriched_text) +VALUES ('1', 'pickup', '10% off on all pickups', 'pickup enriched'), + ('2', 'donate', 'We accept your valuable donations via cards', 'donate enriched'), + ('3', 'worldwide', 'We delivery anywhere with care', 'worldwide enriched'); + +drop table if exists public.app_config CASCADE; +create table public.app_config +( + id TEXT PRIMARY KEY, + feed_date TIMESTAMPTZ NOT NULL DEFAULT NOW(), + name TEXT NOT NULL default 'Fake name', + data jsonb +); +insert into public.app_config (id, data) +values ('seo', '{ "some": "data", "other": "more data"}'); + +drop view if exists public.v_metadata; +CREATE VIEW public.v_metadata AS SELECT - substr(md5(random()::text), 1, 10) AS name, - (ARRAY['cat', 'dog', 'parrot', 'rabbit'])[floor(random() * 4 + 1)::int] AS type, - floor(random() * 50000 + 1)::int AS shop_id -FROM generate_series(1, 50000); + m.id, + m.type, + m.title, + me.enriched_text +FROM public.metadata m + LEFT JOIN public.metadata_enriched me ON m.id = me.id + LEFT JOIN LATERAL ( + SELECT data as config + FROM public.app_config + WHERE id = 'seo' + LIMIT 1 + ) sc ON TRUE; + +drop table if exists public.image; +create table public.image( + parent_type text, + parent_id text, + type text, + original text, + dim64x64 text, + dim128x128 text, + + primary key (parent_type, parent_id, type) +); +insert into public.image (parent_type, parent_id, type, original, dim64x64, dim128x128) +values ('shop', '1', 'front', 'http://fake-original', 'http://fake-64', null), +('shop', '2', 'front', 'http://fake-original', 'http://fake-64', 'http://fake-128'); -CREATE OR REPLACE FUNCTION public.get_shop_info(id_param integer) +CREATE OR REPLACE FUNCTION public.get_shop_info(id_param text) RETURNS json AS $$ DECLARE result_row json; diff --git a/yarn.lock b/yarn.lock index b4c0fa3..21492d7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,14 @@ # yarn lockfile v1 +"@axinom/pg-grouped-attributes-plugin@^0.0.2-beta.15": + version "0.0.2-beta.15" + resolved "https://registry.yarnpkg.com/@axinom/pg-grouped-attributes-plugin/-/pg-grouped-attributes-plugin-0.0.2-beta.15.tgz#222dfc86302f3d197d38714b18d2275508776c46" + integrity sha512-xOXTiZVNSYtWCtzb4kuHU+722AY87nIp8c2evFL1jfPBUQSnzFM6uk3sghDN3/TeDwX6EORfATx/Qy07uI5rJg== + dependencies: + "@dataplan/pg" "^0.0.1-beta.32" + postgraphile "^5.0.0-beta.40" + "@cspotcode/source-map-support@^0.8.0": version "0.8.1" resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" @@ -17,7 +25,7 @@ chalk "^4.1.2" tslib "^2.6.2" -"@dataplan/pg@0.0.1-beta.32": +"@dataplan/pg@0.0.1-beta.32", "@dataplan/pg@^0.0.1-beta.32": version "0.0.1-beta.32" resolved "https://registry.yarnpkg.com/@dataplan/pg/-/pg-0.0.1-beta.32.tgz#d4e4f5b3d5914bd9b3df3d3eec745562f296955b" integrity sha512-XQ5XK+P4CpeD7zi2IQI6MLL5RJwZowUw3acgcOw6fNrS833eHRn3fmY4HKGPUT/hMZwKX/Rah1mmhnFB/HQgmQ== From 5038014ee12a303e1fce831395956f1974b4715c Mon Sep 17 00:00:00 2001 From: Achintha Weerasinghe Date: Thu, 17 Apr 2025 19:52:14 +0530 Subject: [PATCH 10/11] removed grouped plugin --- graphile.config.mjs | 3 +-- package.json | 1 - plugins.mjs | 13 +++++++++++-- schema.sql | 45 ++++++--------------------------------------- yarn.lock | 10 +--------- 5 files changed, 19 insertions(+), 53 deletions(-) diff --git a/graphile.config.mjs b/graphile.config.mjs index cc54bc1..b476652 100644 --- a/graphile.config.mjs +++ b/graphile.config.mjs @@ -12,7 +12,6 @@ import { PgOmitArchivedPlugin } from "@graphile-contrib/pg-omit-archived"; import { dirname } from "path"; import { fileURLToPath } from "url"; import { myExtensions } from "./plugins.mjs"; -import { createPgGroupedAttributesPlugin } from "@axinom/pg-grouped-attributes-plugin"; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); @@ -36,7 +35,7 @@ const preset = { PgAggregatesPreset, // PgSimplifyInflectionPreset ], - plugins: [PersistedPlugin.default, PgOmitArchivedPlugin, TagsFilePlugin, createPgGroupedAttributesPlugin({ separator: '__' }), myExtensions], + plugins: [PersistedPlugin.default, PgOmitArchivedPlugin, TagsFilePlugin, myExtensions], pgServices: [ makePgService({ // Database connection string: diff --git a/package.json b/package.json index 65a3314..931b019 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,6 @@ "postgraphile": "postgraphile" }, "dependencies": { - "@axinom/pg-grouped-attributes-plugin": "^0.0.2-beta.15", "@grafserv/persisted": "^0.0.0-beta.34", "@graphile-contrib/pg-many-to-many": "^2.0.0-beta.7", "@graphile-contrib/pg-omit-archived": "^4.0.0-beta.4", diff --git a/plugins.mjs b/plugins.mjs index 90f3810..0c58af6 100644 --- a/plugins.mjs +++ b/plugins.mjs @@ -14,13 +14,14 @@ export const myExtensions = makeExtendSchemaPlugin((build) => { return { typeDefs: gql` extend type Query { - shopsByIds(ids: [Int!]!): [Shop]! + shopsByIds(ids: [String!]!): [Shop]! } extend type Shop { info: ShopInfo owner: Owner options: MetaOptions + image: Image } type ShopInfo { @@ -48,6 +49,14 @@ export const myExtensions = makeExtendSchemaPlugin((build) => { info($parent) { return $parent; }, + image($parent) { + const $layouts = image.find({ + parent_id: $parent.get('id'), + parent_type: 'shop', + type: 'front', + }); + return $layouts.single(); + }, owner($parent) { return owner .find({ @@ -88,7 +97,7 @@ export const myExtensions = makeExtendSchemaPlugin((build) => { }); return $layouts.single(); } - } + }, }, }; }); diff --git a/schema.sql b/schema.sql index bcb257c..8d94306 100644 --- a/schema.sql +++ b/schema.sql @@ -14,12 +14,7 @@ create table public.shop( owner_id text, di_pickup text, di_worldwide text, - dis_special text, - front__title text, - front__description text, - front__image__title text, - front__image__caption text, - front__image__alt_text text + dis_special text ); INSERT INTO public.shop ( id, @@ -28,12 +23,7 @@ INSERT INTO public.shop ( owner_id, di_pickup, di_worldwide, - dis_special, - front__title, - front__description, - front__image__title, - front__image__caption, - front__image__alt_text + dis_special ) VALUES ( '1', 'One', @@ -41,12 +31,7 @@ INSERT INTO public.shop ( '1', '1', '2', - '3', - 'Front title', - 'Front Description', - 'Front image title', - 'Front image caption', - 'Front image alt text' + '3' ), ( '2', @@ -55,12 +40,7 @@ INSERT INTO public.shop ( '2', '1', '2', - '3', - 'Front title', - 'Front Description', - 'Front image title', - 'Front image caption', - 'Front image alt text' + '3' ), ( '3', @@ -69,12 +49,7 @@ INSERT INTO public.shop ( '1', '1', '2', - '3', - 'Front title', - 'Front Description', - 'Front image title', - 'Front image caption', - 'Front image alt text' + '3' ), ( '4', @@ -83,16 +58,8 @@ INSERT INTO public.shop ( '2', '1', '2', - '3', - 'Front title', - 'Front Description', - 'Front image title', - 'Front image caption', - 'Front image alt text' + '3' ); -comment on table public.shop is $$ - @group front -$$; drop table if exists public.pet; create table public.pet( diff --git a/yarn.lock b/yarn.lock index 21492d7..b4c0fa3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,14 +2,6 @@ # yarn lockfile v1 -"@axinom/pg-grouped-attributes-plugin@^0.0.2-beta.15": - version "0.0.2-beta.15" - resolved "https://registry.yarnpkg.com/@axinom/pg-grouped-attributes-plugin/-/pg-grouped-attributes-plugin-0.0.2-beta.15.tgz#222dfc86302f3d197d38714b18d2275508776c46" - integrity sha512-xOXTiZVNSYtWCtzb4kuHU+722AY87nIp8c2evFL1jfPBUQSnzFM6uk3sghDN3/TeDwX6EORfATx/Qy07uI5rJg== - dependencies: - "@dataplan/pg" "^0.0.1-beta.32" - postgraphile "^5.0.0-beta.40" - "@cspotcode/source-map-support@^0.8.0": version "0.8.1" resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" @@ -25,7 +17,7 @@ chalk "^4.1.2" tslib "^2.6.2" -"@dataplan/pg@0.0.1-beta.32", "@dataplan/pg@^0.0.1-beta.32": +"@dataplan/pg@0.0.1-beta.32": version "0.0.1-beta.32" resolved "https://registry.yarnpkg.com/@dataplan/pg/-/pg-0.0.1-beta.32.tgz#d4e4f5b3d5914bd9b3df3d3eec745562f296955b" integrity sha512-XQ5XK+P4CpeD7zi2IQI6MLL5RJwZowUw3acgcOw6fNrS833eHRn3fmY4HKGPUT/hMZwKX/Rah1mmhnFB/HQgmQ== From 212ed643755ed9228ee3b07ab9e5ad32ce1888ba Mon Sep 17 00:00:00 2001 From: Achintha Weerasinghe Date: Thu, 17 Apr 2025 20:24:25 +0530 Subject: [PATCH 11/11] refactor --- plugins.mjs | 10 +++++----- schema.sql | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins.mjs b/plugins.mjs index 0c58af6..72ec0a2 100644 --- a/plugins.mjs +++ b/plugins.mjs @@ -8,7 +8,7 @@ export const myExtensions = makeExtendSchemaPlugin((build) => { pgResources: { shop, owner, v_metadata, image, get_shop_info }, }, }, - grafast: { each, constant, lambda, connection, object }, + grafast: { each, constant, lambda, object }, } = build; return { @@ -25,8 +25,8 @@ export const myExtensions = makeExtendSchemaPlugin((build) => { } type ShopInfo { - petInfo(filter: String): JSON - customersInfo(filter: String): JSON + petInfo: JSON + customersInfo: JSON } type MetaOptions { @@ -77,12 +77,12 @@ export const myExtensions = makeExtendSchemaPlugin((build) => { } }, ShopInfo: { - petInfo($parent, { $filter }) { + petInfo($parent) { const $fnData = get_shop_info.execute([{ step: $parent.get('id'), pgCodec: TYPES.int, name: 'id_param' }], 'normal') return $fnData; }, - customersInfo($parent, { $filter }) { + customersInfo($parent) { const $fnData = get_shop_info.execute([{ step: $parent.get('id'), pgCodec: TYPES.int, name: 'id_param' }], 'normal') return $fnData; diff --git a/schema.sql b/schema.sql index 8d94306..7adc96c 100644 --- a/schema.sql +++ b/schema.sql @@ -45,7 +45,7 @@ INSERT INTO public.shop ( ( '3', 'Three', - true, + false, '1', '1', '2',