File tree Expand file tree Collapse file tree 4 files changed +86
-0
lines changed Expand file tree Collapse file tree 4 files changed +86
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Ping PostgreSQL
2
+
3
+ Simple schema that when deployed provides an easy way to check that a
4
+ PostgreSQL database can be connected to from a GraphQL endpoint.
5
+
6
+ ## Setup
7
+
8
+ Either set an environment variable or an ` .env ` file containing the URI of the PostgreSQL instance.
9
+
10
+ Replace ` <<xxx>> ` values with the correct connection information.
11
+
12
+ If a port number is required then add it to the host as ` :1234 ` .
13
+
14
+ If the password contains special characters then must be URL escaped.
15
+
16
+ ### Environment variable
17
+ ```
18
+ export STEPZEN_PG_DB_URI=postgresql://<<host>>/<<database>>?user=<<user>>&password=<<password>>
19
+ ```
20
+
21
+ ### ` .env ` contents
22
+
23
+ ```
24
+ STEPZEN_PG_DB_URI=postgresql://<<host>>/<<database>>?user=<<user>>&password=<<password>>
25
+ ```
26
+
27
+ ## Deploy
28
+
29
+ ```
30
+ stepzen deploy
31
+ ```
32
+
33
+ ## Test
34
+
35
+ ```
36
+ stepzen request '{ping{status}}'
37
+ ```
38
+
39
+ ## Example
40
+
41
+ ```
42
+ >stepzen deploy
43
+ Deploying dbping/postgresql to StepZen... done in 443ms 🚀
44
+ ✓ 🔐 https://danville.us-east-a.ibm.stepzen.net/dbping/postgresql/__graphql
45
+ ✓ 🔐 wss://danville.us-east-a.ibm.stepzen.net/stepzen-subscriptions/dbping/postgresql/__graphql (subscriptions)
46
+
47
+ You can test your hosted API with curl:
48
+
49
+ curl https://danville.us-east-a.ibm.stepzen.net/dbping/postgresql/__graphql \
50
+ --header "Authorization: Apikey $(stepzen whoami --apikey)" \
51
+ --header "Content-Type: application/json" \
52
+ --data-raw '{
53
+ "query": "query SampleQuery { __schema { description queryType { fields {name} } } }"
54
+ }'
55
+
56
+ stepzen request '{ping{status}}'
57
+ {
58
+ "data": {
59
+ "ping": {
60
+ "status": "ok"
61
+ }
62
+ }
63
+ }
64
+ ```
Original file line number Diff line number Diff line change
1
+ configurationset :
2
+ - configuration :
3
+ name : pgdb
4
+ uri : STEPZEN_PG_DB_URI
Original file line number Diff line number Diff line change
1
+ type Query {
2
+ """
3
+ Pings the configured database by running a SQL statement
4
+ that does not access any user tables or schema.
5
+ """
6
+ ping : Ping
7
+ @dbquery (
8
+ type : " postgresql"
9
+ query : " SELECT 'ok' AS status"
10
+ configuration : " pgdb"
11
+ )
12
+ }
13
+ type Ping {
14
+ status : String
15
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "endpoint" : " dbping/postgresql"
3
+ }
You can’t perform that action at this time.
0 commit comments