Skip to content

Commit 987dc25

Browse files
committed
chore: postgresql ping schema
1 parent e9d0535 commit 987dc25

File tree

4 files changed

+86
-0
lines changed

4 files changed

+86
-0
lines changed

dbquery/pings/postgresql/README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
configurationset:
2+
- configuration:
3+
name: pgdb
4+
uri: STEPZEN_PG_DB_URI
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"endpoint": "dbping/postgresql"
3+
}

0 commit comments

Comments
 (0)