Skip to content

Commit

Permalink
Add example scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
smyrick committed Oct 2, 2024
1 parent 724e1bb commit 3c5cfad
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,34 @@ You can run this project as a [Docker image](https://github.com/apollosolutions/

Here's how to use the pre-built Docker image, mounting a local `config.yml` to a container and using it as a configuration:
```
docker run -p 8080:8080 --mount "type=bind,source=./config.yml,target=/app/config.yml" ghcr.io/apollosolutions/persisted-query-to-rest:v0.1.1 --config /app/config.yml
docker run -p 8080:8080 --mount "type=bind,source=./config.yml,target=/app/config.yml" ghcr.io/apollosolutions/persisted-query-to-rest:latest --config /app/config.yml
```

## Usage

There are two flags for `persisted-query-to-rest`:
There is one flag for `persisted-query-to-rest`:

* `--config`, which specifies the config location
* `--config-schema` which forces the application to print out a JSON schema for YAML validation
* See [example_config.yaml](./example_config.yaml) to see an example of setting it up
* We use [Red Hat's YAML extension for VSCode](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) to validate

## Configuration

See [`example_config.yaml`](./example_config.yaml) for a complete example of a configuration.

### Generate a configuration schema
To generate a YAML schema file you can run the binary with the command `config-schema`. This file can then be configured in your config YAML file to provide autocomplete and validation of the YAML file right in your IDE

```shell
# forces the application to print out a JSON schema for YAML validation
./persisted-query-to-rest config-schema > config-schema.json
```
OR
```shell
docker run ghcr.io/apollosolutions/persisted-query-to-rest:latest config-schema > config-schema.json
```

* See [example_config.yaml](./example_config.yaml) to see an example of setting it up
* We use [Red Hat's YAML extension for VSCode](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) to validate

### Common

This configuration contains the general configuration settings for `persisted-query-to-rest`.
Expand Down
1 change: 1 addition & 0 deletions example/config-schema.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker run ghcr.io/apollosolutions/persisted-query-to-rest:v0.3.2 config-schema > config-schema.json
11 changes: 11 additions & 0 deletions example/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# yaml-language-server: $schema=config-schema.json
common:
path_prefix: "/api/v1"
listen: "0.0.0.0:8080"
graphql_endpoint: "https://api.graphql-gtm-demo.com/e-commerce-gtm-demo/"
logging:
level: info

endpoints:
- path: "/userInfo"
pq_id: "126c4cf641bff8deba6c863e00e0dc136f31374425d22339e9779a91ae4494d8"
5 changes: 5 additions & 0 deletions example/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
docker run \
-p 8080:8080 \
--mount "type=bind,source=./config.yml,target=/app/config.yml" \
--name persisted-query-to-rest \
ghcr.io/apollosolutions/persisted-query-to-rest:v0.3.2 --config /app/config.yml

0 comments on commit 3c5cfad

Please sign in to comment.