File tree Expand file tree Collapse file tree 3 files changed +54
-12
lines changed Expand file tree Collapse file tree 3 files changed +54
-12
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ services:
6
6
build :
7
7
context : .
8
8
dockerfile : ./dockerfiles/db/Dockerfile
9
+ args :
10
+ PG_VERSION : 17
9
11
volumes :
10
12
- ./dockerfiles/db/setup.sql:/docker-entrypoint-initdb.d/setup.sql
11
13
ports :
Original file line number Diff line number Diff line change 1
- ARG PG_VERSION=15
1
+ ARG PG_VERSION=17
2
2
FROM postgres:${PG_VERSION}
3
3
RUN apt-get update
4
4
@@ -35,6 +35,6 @@ RUN cargo pgrx init --pg${PG_MAJOR} $(which pg_config)
35
35
USER root
36
36
37
37
COPY . .
38
- RUN cargo pgrx install
38
+ RUN cargo pgrx install --release --features pg${PG_MAJOR}
39
39
40
40
USER postgres
Original file line number Diff line number Diff line change 2
2
< html lang ="en ">
3
3
< head >
4
4
< title > GraphiQL - pg_graphql</ title >
5
-
6
- < link rel ="stylesheet " href ="https://unpkg.com/graphiql/graphiql.min.css " />
5
+ < link rel ="
stylesheet "
href ="
https://unpkg.com/[email protected] /graphiql.min.css "
/>
7
6
</ head >
8
7
9
8
< body style ="margin: 0 ">
18
17
> </ script >
19
18
< script
20
19
crossorigin
21
- src ="https://unpkg.com/graphiql/graphiql.min.js "
20
+ src ="https://unpkg.com/graphiql@3.0.6 /graphiql.min.js "
22
21
> </ script >
23
22
< script >
24
- const fetcher = GraphiQL . createFetcher ( {
25
- url : "http://localhost:3001/rpc/graphql" ,
26
- } ) ;
27
- ReactDOM . render (
28
- React . createElement ( GraphiQL , { fetcher : fetcher } ) ,
29
- document . getElementById ( "graphiql" )
30
- ) ;
23
+ // Custom fetcher for PostgREST GraphQL function
24
+ const fetcher = async ( graphQLParams ) => {
25
+ const response = await fetch ( "http://localhost:3001/rpc/graphql" , {
26
+ method : 'POST' ,
27
+ headers : {
28
+ 'Accept' : 'application/vnd.pgrst.object+json;nulls=stripped' ,
29
+ 'Content-Type' : 'application/json'
30
+ } ,
31
+ body : JSON . stringify ( {
32
+ query : graphQLParams . query ,
33
+ variables : graphQLParams . variables || { } ,
34
+ operationName : graphQLParams . operationName || null ,
35
+ extensions : null
36
+ } )
37
+ } ) ;
38
+
39
+ return response . json ( ) ;
40
+ } ;
41
+
42
+ const defaultQuery = `# Welcome to pg_graphql!
43
+ # Try this query:
44
+
45
+ query {
46
+ accountCollection {
47
+ edges {
48
+ node {
49
+ id
50
+ email
51
+ createdAt
52
+ blogCollection {
53
+ edges {
54
+ node {
55
+ id
56
+ name
57
+ description
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+ }
64
+ }` ;
65
+
66
+ const root = ReactDOM . createRoot ( document . getElementById ( "graphiql" ) ) ;
67
+ root . render ( React . createElement ( GraphiQL , {
68
+ fetcher : fetcher ,
69
+ query : defaultQuery
70
+ } ) ) ;
31
71
</ script >
32
72
</ body >
33
73
</ html >
You can’t perform that action at this time.
0 commit comments