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:
66 build :
77 context : .
88 dockerfile : ./dockerfiles/db/Dockerfile
9+ args :
10+ PG_VERSION : 17
911 volumes :
1012 - ./dockerfiles/db/setup.sql:/docker-entrypoint-initdb.d/setup.sql
1113 ports :
Original file line number Diff line number Diff line change 1- ARG PG_VERSION=15
1+ ARG PG_VERSION=17
22FROM postgres:${PG_VERSION}
33RUN apt-get update
44
@@ -35,6 +35,6 @@ RUN cargo pgrx init --pg${PG_MAJOR} $(which pg_config)
3535USER root
3636
3737COPY . .
38- RUN cargo pgrx install
38+ RUN cargo pgrx install --release --features pg${PG_MAJOR}
3939
4040USER postgres
Original file line number Diff line number Diff line change 22< html lang ="en ">
33 < head >
44 < 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 "
/> 76 </ head >
87
98 < body style ="margin: 0 ">
1817 > </ script >
1918 < script
2019 crossorigin
21- src ="https://unpkg.com/graphiql/graphiql.min.js "
20+ src ="https://unpkg.com/graphiql@3.0.6 /graphiql.min.js "
2221 > </ script >
2322 < 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+ } ) ) ;
3171 </ script >
3272 </ body >
3373</ html >
You can’t perform that action at this time.
0 commit comments