diff --git a/babel.config.js b/babel.config.js index 5dc22ea185..bd5d24b735 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,4 +1,4 @@ -// Babel config, used by Jest? +// Babel config, used by Jest module.exports = { plugins: ["@babel/plugin-transform-modules-commonjs"], presets: [ diff --git a/postgraphile/postgraphile/graphile.config.ts b/postgraphile/postgraphile/graphile.config.ts index 14c9cacacf..55aa7d6e1a 100644 --- a/postgraphile/postgraphile/graphile.config.ts +++ b/postgraphile/postgraphile/graphile.config.ts @@ -1,4 +1,6 @@ /* eslint-disable import/no-unresolved */ +import type { PgSelectSingleStep } from "@dataplan/pg"; +import { TYPES } from "@dataplan/pg"; import PersistedPlugin from "@grafserv/persisted"; import { EXPORTABLE, exportSchema } from "graphile-export"; import { gql, makeExtendSchemaPlugin } from "graphile-utils"; @@ -199,6 +201,28 @@ const NonNullRelationsPlugin: GraphileConfig.Plugin = { const preset: GraphileConfig.Preset = { plugins: [ StreamDeferPlugin, + makeExtendSchemaPlugin((build) => { + const { sql } = build; + return { + typeDefs: gql` + extend type Person { + greet(greeting: String! = "Hello"): String + } + `, + plans: { + Person: { + greet($user: PgSelectSingleStep, { $greeting }) { + const placeholderSql = $user.placeholder($greeting, TYPES.text); + const alias = $user.getClassStep().alias; + return $user.select( + sql`${placeholderSql} || ', ' || ${alias}.name`, + TYPES.text, + ); + }, + }, + }, + }; + }), makeExtendSchemaPlugin({ typeDefs: gql` extend type Query {