Skip to content

Commit 8f9a6f0

Browse files
feat(snippet): add example for @dbquery with SQL queries
1 parent 25089fc commit 8f9a6f0

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

dbquery/custom-query/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ This allows you to fetch exactly the data you need, based on the custom SQL quer
4545

4646
## Try it Out!
4747

48-
Deploy the schema from `dbquery/pagination` relative to the repository's root directory:
48+
Deploy the schema from `dbquery/custom-query` relative to the repository's root directory:
4949

5050
```
5151
stepzen deploy

dbquery/custom-query/api.graphql

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type Query {
3737
- `type`: Specifies the type of database being queried. In this case, it’s a PostgreSQL database.
3838
- `configuration`: References the database configuration (connection details) in StepZen.
3939
40-
This query does not take any arguments, and hence there are no parameter markers in the SQL query.
40+
This field does not take any arguments, and hence there are no parameter markers in the SQL query.
4141
The SQL query is static, always returning all customers from the database.
4242
"""
4343
customers: [Customer]
@@ -51,17 +51,16 @@ type Query {
5151
Fetches a single customer by their ID from the database.
5252
5353
**Field Argument to Parameter Marker Mapping**:
54-
- The `id` argument provided in the GraphQL query maps to the `$1` marker in the SQL query.
55-
- SQL queries typically use numbered markers (e.g., `$1`, `$2`, etc.) for parameterized inputs. The number refers to the position of the argument in the query.
56-
- When a query is executed, the value passed to the `id` argument in GraphQL (via variables) will replace the `$1` marker in the SQL query.
54+
- Maps the `id` argument to the `$1` marker in the SQL query, allowing dynamic ID-based retrieval.
55+
- `$1` serves as a placeholder, which will be replaced by the provided `id` value during execution.
5756
5857
**@dbquery Directive Usage**:
5958
- `query`: This is the SQL query that will be executed. Here, the customer data is fetched based on the provided `id` value.
6059
- The `$1` marker is a placeholder for the value of the `id` argument, which is passed as a variable when executing the query.
6160
- `type`: Specifies the type of database being queried (PostgreSQL).
6261
- `configuration`: References the database configuration (connection details) in StepZen.
6362
64-
This query requires an `id` argument as input, which is passed as a variable from the GraphQL query. The variable's value is used to fetch the corresponding customer from the database.
63+
This field requires an `id` argument as input, which is passed as a variable from the GraphQL request. The variable's value is used to fetch the corresponding customer from the database.
6564
"""
6665
customer(id: Int!): Customer
6766
@dbquery(

0 commit comments

Comments
 (0)