Skip to content

Commit bd02837

Browse files
authored
Merge pull request #215 from supabase/docs_kaizen
Docs Update
2 parents a83f0e3 + 96fae25 commit bd02837

File tree

8 files changed

+1369
-158
lines changed

8 files changed

+1369
-158
lines changed

docs/api.md

Lines changed: 1289 additions & 56 deletions
Large diffs are not rendered by default.

docs/example_schema.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The following is a complete example showing how a sample SQL schema translates into a GraphQL schema.
2+
3+
```sql
4+
--8<-- "docs/assets/demo_schema.sql"
5+
```
6+
7+
```graphql
8+
--8<-- "docs/assets/demo_schema.graphql"
9+
```

docs/index.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919

2020
- [x] __Performant__
2121
- [x] __Consistent__
22-
- [x] __Serverless__
2322
- [x] __Open Source__
2423

2524
### Overview
26-
`pg_graphql` reflects a GraphQL schema from the existing SQL schema.
25+
`pg_graphql` is a PostgreSQL extension that enables querying the database with GraphQL using a single a SQL function.
2726

28-
The extension keeps schema translation and query resolution neatly contained on your database server. This enables any programming language that can connect to PostgreSQL to query the database via GraphQL with no additional servers, processes, or libraries.
27+
The extension reflects a GraphQL schema from the existing SQL schema and exposes it through a SQL function, `graphql.resolve(...)`. This enables any programming language that can connect to PostgreSQL to query the database via GraphQL with no additional servers, processes, or libraries.
2928

3029

3130
### TL;DR
@@ -63,6 +62,6 @@ create table blog_post(
6362
```
6463
Translates into a GraphQL schema displayed below.
6564

66-
Each table receives an entrypoint in the top level `Query` type that is a pageable collection with relationships defined by its foreign keys. Tables similarly recieve entrypoints in the `Mutation` schema that enable bulk operations for insert, update, and delete.
65+
Each table receives an entrypoint in the top level `Query` type that is a pageable collection with relationships defined by its foreign keys. Tables similarly recieve entrypoints in the `Mutation` type that enable bulk operations for insert, update, and delete.
6766

6867
![GraphiQL](./assets/quickstart_graphiql.png)

docs/performance.md

Lines changed: 0 additions & 69 deletions
This file was deleted.

docs/reflection.md

Lines changed: 0 additions & 27 deletions
This file was deleted.

docs/requirements_docs.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
mkdocs
22
mkdocs-material
3+
git+https://github.com/ivome/pygments-graphql-lexer.git

docs/sql_interface.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
pg_graphql's public facing SQL interface consists of a single SQL function to resolve GraphQL requests. All other entities in the `graphql` schema are private.
2+
3+
4+
### graphql.resolve
5+
6+
##### description
7+
Resolves a GraphQL query, returning JSONB.
8+
9+
##### signature
10+
```sql
11+
graphql.resolve(
12+
-- graphql query/mutation
13+
query text,
14+
-- json key/values pairs for variables
15+
variables jsonb default '{}'::jsonb,
16+
-- the name of the graphql operation in *query* to execute
17+
"operationName" text default null,
18+
-- extensions to include in the request
19+
extensions jsonb default null,
20+
)
21+
returns jsonb
22+
23+
strict
24+
volatile
25+
parallel safe
26+
language plpgsql
27+
```
28+
29+
##### usage
30+
31+
```sql
32+
-- Create the extension
33+
graphqldb= create extension pg_graphql;
34+
CREATE EXTENSION
35+
36+
-- Create an example table
37+
graphqldb= create table book(id int primary key, title text);
38+
CREATE TABLE
39+
40+
-- Insert a record
41+
graphqldb= insert into book(id, title) values (1, 'book 1');
42+
INSERT 0 1
43+
44+
-- Query the table via GraphQL
45+
graphqldb= select graphql.resolve($$
46+
query {
47+
bookCollection {
48+
edges {
49+
node {
50+
id
51+
}
52+
}
53+
}
54+
}
55+
$$);
56+
57+
resolve
58+
----------------------------------------------------------------------
59+
{"data": {"bookCollection": {"edges": [{"node": {"id": 1}}]}}, "errors": []}
60+
```

mkdocs.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ repo_url: https://github.com/supabase/pg_graphql
88
nav:
99
- Welcome: 'index.md'
1010
- Quickstart: 'quickstart.md'
11+
- SQL Interface: 'sql_interface.md'
1112
- API: 'api.md'
12-
- Reflection: 'reflection.md'
1313
- Computed Fields: 'computed_fields.md'
1414
- Security: 'security.md'
1515
- Configuration: 'configuration.md'
16-
- Performance: 'performance.md'
16+
- Example Schema: 'example_schema.md'
1717
- Installation: 'installation.md'
1818
- Contributing: 'contributing.md'
1919

@@ -29,7 +29,12 @@ theme:
2929
markdown_extensions:
3030
- pymdownx.highlight:
3131
linenums: true
32+
guess_lang: false
33+
use_pygments: true
34+
pygments_style: default
3235
- pymdownx.superfences
36+
- pymdownx.tabbed:
37+
alternate_style: true
3338
- pymdownx.snippets
3439
- pymdownx.tasklist
3540
- admonition

0 commit comments

Comments
 (0)