Skip to content

Commit

Permalink
down to functions.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jemgillam committed Feb 17, 2025
1 parent 1666c08 commit 971a964
Show file tree
Hide file tree
Showing 20 changed files with 82 additions and 79 deletions.
8 changes: 4 additions & 4 deletions postgraphile/website/postgraphile/evaluating.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Evaluating PostGraphile
---

# Does PostGraphile Fit Your Project?
# Does PostGraphile fit your project?

Hopefully you’ve been convinced that PostGraphile serves an awesome GraphQL API,
but now let’s take a more critical look at whether or not you should adopt
Expand All @@ -19,7 +19,7 @@ optimizing your database. Scaling a database is well-understood — and you can
combine techniques — scaling vertically with larger database servers (more RAM,
faster storage), or horizontally with read replicas.

### No Lock-In
### No lock-in

PostGraphile does not lock you into using PostGraphile forever — in fact most of
the work you do implementing a PostGraphile API is in your database, which you
Expand Down Expand Up @@ -47,7 +47,7 @@ simple exit path even years into the business. We welcome your contributions to
help PostGraphile scale and meet your needs, and are very open to sponsored
improvements to the software.

### Schema Driven APIs
### Schema-driven APIs

If you fundamentally disagree with “one-to-one mapping of a SQL schema to an
API” (GraphQL or otherwise) this section is for you.
Expand Down Expand Up @@ -98,7 +98,7 @@ idea:
serialization/deserialization and data transfer costs are eliminated since
no data is transferred to remote clients.

Still worried about a certain aspect of a schema driven API? Open an issue,
Still worried about a certain aspect of a schema-driven API? Open an issue,
we’re confident we can convince you otherwise 😉

[^1]:
Expand Down
2 changes: 1 addition & 1 deletion postgraphile/website/postgraphile/extending-raw.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Graphile Build
---

# Schema Plugins — Graphile Build
# Schema plugins — Graphile Build

The PostGraphile GraphQL schema is constructed out of a number of Graphile
Build plugins. The core PG-related plugins can be found here:
Expand Down
4 changes: 2 additions & 2 deletions postgraphile/website/postgraphile/extending.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const FullNameToNamePlugin = {
};
```
### Writing Plugins
### Writing plugins
We’ve created a number of plugin helpers for common tasks:
Expand All @@ -56,7 +56,7 @@ Do look over our [plugin gallery](./plugin-gallery) for examples of plugins.
These are generally suitable for copying/pasting into your app and then
customizing to your needs.
### Loading Plugins
### Loading plugins
Once you’ve written (or installed) a plugin, you can load it via your preset:
Expand Down
2 changes: 1 addition & 1 deletion postgraphile/website/postgraphile/filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To add a condition to an existing condition another option is the
can also augment PostGraphile’s existing connections using custom [Graphile
Engine plugins](./extending-raw), such as the following:

#### Filter Plugin
#### The filter plugin

:::warning Generic filtering capabilities could be a mistake

Expand Down
8 changes: 4 additions & 4 deletions postgraphile/website/postgraphile/function-gallery.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Function gallery
---

# Database Function Gallery
# Database function gallery

:::caution

Expand All @@ -18,7 +18,7 @@ _This page is a WIP — sorry that it's hard to read right now, we will definite
be tidying it up! If you want to help with this, please pop into our
[discord chat](http://discord.gg/graphile) and volunteer!_

## Custom Queries
## Custom queries

### Logged in user field

Expand Down Expand Up @@ -51,7 +51,7 @@ $$ language sql stable set search_path from current;
forumByNodeId(
```

## Computed Columns
## Computed columns

### User primary email

Expand Down Expand Up @@ -87,7 +87,7 @@ $$ language sql stable set search_path from current;
"""
```

## Custom Mutations
## Custom mutations

### Insert multiple records

Expand Down
8 changes: 4 additions & 4 deletions postgraphile/website/postgraphile/function-restrictions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
title: Function restrictions
---

# Database Function Restrictions
# Database function restrictions

PostGraphile supports a wide range of PostgreSQL functions; however we do not
support:

- VARIADIC functions
- overloaded functions (because it’s not currently possible to expose them
- Overloaded functions (because it’s not currently possible to expose them
neatly over GraphQL)
- functions that return `record` without any more type information (because we
- Functions that return `record` without any more type information (because we
don’t know what columns that `record` will contain, and thus cannot convert it
to GraphQL)
to solve this, change `record` to be the name of a composite type that
To solve this, change `record` to be the name of a composite type that
you’ve defined with `CREATE TYPE` (or similar)
22 changes: 12 additions & 10 deletions postgraphile/website/postgraphile/functions.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
---
title: Database functions
title: Functions
---

# Database functions

One of the easiest ways to add more capabilities to your PostGraphile schema is
with PostgreSQL functions. The three main methods are:

- [Computed Columns](./computed-columns) enable you to add a computed field to
- [Computed columns](./computed-columns) enable you to add a computed field to
a table type
- [Custom Queries](./custom-queries) enable you to add a root level Query field
- [Custom queries](./custom-queries) enable you to add a root level Query field
which can return a scalar, list, custom type, table row or even a table
connection
- [Custom Mutations](./custom-mutations) enable you to add a root level
- [Custom mutations](./custom-mutations) enable you to add a root level
Mutation field which can cause modifications to your database and return
nothing (`void`), a scalar, list, custom type, table row or list of table rows
(but not a connection, since you cannot paginate over a mutation)
Expand Down Expand Up @@ -159,7 +161,7 @@ millions of rows per second (and even more if it just needs index values), so
determining the list of `organization_id`s a user is a member of is so trivial
you can almost ignore it.

## Recommended Reading
## Recommended reading

- PostgreSQL [`CREATE FUNCTION`][] documentation for actually creating
functions.
Expand All @@ -170,7 +172,7 @@ you can almost ignore it.
[`create trigger`]: http://www.postgresql.org/docs/current/static/sql-createtrigger.html
[computed columns in postgresql]: http://stackoverflow.com/a/11166268/1568890

## Procedural Languages
## Procedural languages

Functions in PostgreSQL require you to use either SQL or a procedural language.
The most common procedural language in PostgreSQL is [PL/pgSQL][pl/pgsql].
Expand Down Expand Up @@ -234,7 +236,7 @@ $$ language plv8 immutable strict;
[javascript (plv8)]: https://github.com/plv8/plv8
[ruby (plruby)]: https://github.com/knu/postgresql-plruby

## Named Arguments
## Named arguments

PostgreSQL allows you to mix named and positional (unnamed) arguments in your
functions. However, GraphQL will _only_ allow named arguments. So if you don’t
Expand Down Expand Up @@ -334,7 +336,7 @@ To better understand these conflicts and solutions, refer to the PostgreSQL docs
for
[variable substitution](https://www.postgresql.org/docs/current/plpgsql-implementation.html#PLPGSQL-VAR-SUBST).

## VOLATILE (Mutation) Functions
## VOLATILE (mutation) functions

By default, a function is “volatile”. For example, a function defined as:

Expand Down Expand Up @@ -369,7 +371,7 @@ methods like `POST`, `PUT`, `PATCH`, and `DELETE`.
Certain VOLATILE functions will be exposed by PostGraphile as
[custom mutations](./custom-mutations).

## STABLE/IMMUTABLE (Query) Functions
## STABLE/IMMUTABLE (query) functions

If your function does not modify any data or state, you should declare it as
`STABLE`.
Expand Down Expand Up @@ -433,7 +435,7 @@ HTTP methods like `GET` and `HEAD`.
Certain STABLE/IMMUTABLE functions will be exposed by PostGraphile as
[custom queries](./custom-queries) or [computed columns](./computed-columns).

## SETOF FunctionsConnections
## SETOF functionsconnections

As well as scalars, compound types, and arrays of these, PostgreSQL functions
can also return sets. Sets emulate tables, and so it’s natural for PostGraphile
Expand Down
12 changes: 6 additions & 6 deletions postgraphile/website/versioned_docs/version-4/evaluating.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Evaluating PostGraphile
---

# Evaluating PostGraphile For Your Project
# Evaluating PostGraphile for your project

Hopefully you’ve been convinced that PostGraphile serves an awesome GraphQL API,
but now let’s take a more critical look at whether or not you should adopt
Expand All @@ -19,7 +19,7 @@ optimizing your database. Scaling a database is well-understood - and you can
combine techniques - scaling vertically with larger database servers (more RAM,
faster storage), or horizontally with read replicas.

### No Lock-In
### No lock-in

PostGraphile does not lock you into using PostGraphile forever - in fact most of
the work you do implementing a PostGraphile API is in your database, which you
Expand All @@ -44,7 +44,7 @@ exit path even years into the business. We welcome your contributions to help
PostGraphile scale and meet your needs, and are very open to sponsored
improvements to the software.

### Schema Driven APIs
### Schema-driven APIs

If you fundamentally disagree with a one-to-one mapping of a SQL schema to an
API (GraphQL or otherwise) this section is for you.
Expand All @@ -54,12 +54,12 @@ of your API. PostGraphile was created to allow you to focus on your product and
not the API. If you need to integrate external systems, there are plugin
interfaces to help you do that, and they're getting easier to use all the time.
If you want a custom API there is a simple transition path (read
[no lock in](#no-lock-in)). If you still can’t get over the one-to-one nature of
[no lock-in](#no-lock-in)). If you still can’t get over the one-to-one nature of
PostGraphile consider the following arguments why putting your business logic in
PostgreSQL is a good idea:

1. PostgreSQL already has a powerful [user management system][user-management]
with fine grained [row level security][row-level-security]. A custom API
with fine grained [row-level security][row-level-security]. A custom API
would mean you have to build your own user management and security, and
having to guarantee that every possible route to your database data is
vetted by the same permissions logic (which PostgreSQL RLS does for you).
Expand All @@ -79,7 +79,7 @@ PostgreSQL is a good idea:
transactions and event reporting), implement a job queue, or add a Graphile
Engine plugin to wrap or replace a PostGraphile resolver.

Still worried about a certain aspect of a schema driven API? Open an issue,
Still worried about a certain aspect of a schema-driven API? Open an issue,
we're confident we can convince you otherwise 😉

[user-management]: http://www.postgresql.org/docs/current/static/user-manag.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Graphile Engine
---

# Schema Plugins — Graphile Engine
# Schema plugins — Graphile Engine

The PostGraphile GraphQL schema is constructed out of a number of Graphile
Engine plugins. The core PG-related plugins can be found here:
Expand Down
4 changes: 2 additions & 2 deletions postgraphile/website/versioned_docs/version-4/extending.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Schema plugins
---

# GraphQL Schema Plugins
# GraphQL schema plugins

PostGraphile's schema generator is built from a number of
[Graphile Engine plugins](https://build.graphile.org/graphile-build/4/plugins). You can
Expand All @@ -12,7 +12,7 @@ or using the raw plugin interface available from Graphile Engine.
_If you're looking for an easy way to remove/rename things, check out
[smart comments](./smart-comments)._

### Writing Plugins
### Writing plugins

We've created a number of plugin helpers for common tasks:

Expand Down
2 changes: 1 addition & 1 deletion postgraphile/website/versioned_docs/version-4/filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ adding fields using [custom queries](./custom-queries),
You can also augment PostGraphile's existing connections using custom
[Graphile Engine plugins](./extending-raw), such as the following:

### Filter Plugin
### The filter plugin

:::warning BEWARE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Function gallery
---

# Database Function Gallery
# Database function gallery

Below you'll find some examples of various PostgreSQL functions, and their
effects on PostGraphile.
Expand All @@ -13,7 +13,7 @@ be tidying it up! If you want to help with this, please pop into our

_All these diffs are automatically produced using the functions as written._

## Custom Queries
## Custom queries

### Logged in user field

Expand Down Expand Up @@ -46,7 +46,7 @@ $$ language sql stable set search_path from current;
forumByNodeId(
```

## Computed Columns
## Computed columns

### User primary email

Expand Down Expand Up @@ -82,7 +82,7 @@ $$ language sql stable set search_path from current;
"""
```

## Custom Mutations
## Custom mutations

### Insert multiple records

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
title: Function restrictions
---

# Database Function Restrictions
# Database function restrictions

PostGraphile supports a wide range of PostgreSQL functions; however we do not
support:

- VARIADIC functions
- overloaded functions (because it's not currently possible to expose them
- Overloaded functions (because it's not currently possible to expose them
neatly over GraphQL)
- functions that return `record` without any more type information (because we
- Functions that return `record` without any more type information (because we
don't know what columns that `record` will contain, and thus cannot convert it
to GraphQL)
- to solve this, change `record` to be the name of a composite type that
- To solve this, change `record` to be the name of a composite type that
you've defined with `CREATE TYPE` (or similar)

### Thanks
Expand Down
Loading

0 comments on commit 971a964

Please sign in to comment.