# pg_graphql — Postgres extension

> A GraphQL API over your tables at /graphql/v1.

Source: https://scribase.com/extensions/pg_graphql

Category: APIs and HTTP. Version: 1.6.2. Optional, enabled per project.

## About

pg_graphql reflects your schema into a GraphQL schema inside the database: each table becomes a collection with filtering, ordering and cursor pagination, and foreign keys become nested fields. Queries are resolved by a single SQL function, so row level security applies as it does for REST.

## Enable it

```sql
create extension if not exists pg_graphql;
```

## Example

```sql
-- resolve a query from SQL
select graphql.resolve($$
  {
    postsCollection(first: 5, orderBy: [{ id: DescNullsLast }]) {
      edges { node { id title } }
    }
  }
$$);

-- or over HTTP: POST <Project URL>/graphql/v1 with the same query
```

Upstream: https://github.com/supabase/pg_graphql