Created
October 26, 2021 09:28
-
-
Save benjie/518fbe7bbaaa96dbeae173976a28e442 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
# What DB are we messing with? (THIS DB WILL BE OVERWRITTEN!) | |
DATABASE="timethor" | |
SCHEMA="main" | |
# Populate database | |
dropdb --if-exists "$DATABASE" | |
createdb "$DATABASE" | |
psql -X1v ON_ERROR_STOP=1 "$DATABASE" <<HERE | |
create schema $SCHEMA; | |
CREATE TABLE main.user(id int PRIMARY KEY, foo text); | |
CREATE TABLE main.product(id int primary key, bar text); | |
CREATE TYPE main.table_history_audit_entry AS ( audit_by int, baz text); | |
COMMENT ON TYPE main.table_history_audit_entry IS E'@foreignKey (audit_by) references main.user (id)'; | |
CREATE OR REPLACE FUNCTION main."product_auditFull"(t main.product) RETURNS SETOF main.table_history_audit_entry AS $\$ select (1, 'hi')::main.table_history_audit_entry $\$ LANGUAGE sql STABLE; | |
HERE | |
# Install deps | |
yarn add --dev postgraphile @graphile-contrib/pg-simplify-inflector | |
# Run PostGraphile | |
yarn postgraphile \ | |
--subscriptions \ | |
--watch \ | |
--dynamic-json \ | |
--no-setof-functions-contain-nulls \ | |
--no-ignore-rbac \ | |
--show-error-stack=json \ | |
--extended-errors hint,detail,errcode \ | |
--append-plugins @graphile-contrib/pg-simplify-inflector \ | |
--graphiql "/" \ | |
--enhance-graphiql \ | |
--allow-explain \ | |
--enable-query-batching \ | |
--legacy-relations omit \ | |
--connection "$DATABASE" \ | |
--schema "$SCHEMA" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With the above DB schema, the below query is valid: