-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from hasura/CLI-updates-june-2024
CLI-updates-june-2024
- Loading branch information
Showing
149 changed files
with
8,462 additions
and
5,846 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "Hasura DDN Dev Container with Docker-in-Docker", | ||
"image": "mcr.microsoft.com/devcontainers/base:ubuntu", // Any generic, debian-based image. | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-in-docker:1": { | ||
"version": "latest", | ||
"moby": true | ||
}, | ||
"ghcr.io/devcontainers/features/node:1": { | ||
"version": "20", | ||
"additionalVersions": "18" | ||
} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": ["HasuraHQ.hasura"], | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/bash", | ||
"terminal.integrated.shellArgs.linux": ["-l"] | ||
} | ||
}, | ||
"codespaces": { | ||
"openFiles": ["CODESPACE_QUICKSTART.md"] | ||
} | ||
}, | ||
|
||
"secrets": { | ||
"HASURA_PAT": { | ||
"description": "Set Hasura PAT for CLI authentication", | ||
"documentationUrl": "https://hasura.io/docs/latest/api-reference/cloud-api-reference/#authentication" | ||
} | ||
}, | ||
"postCreateCommand": "curl -L https://graphql-engine-cdn.hasura.io/ddn/cli/v2/get.sh | bash && ddn auth login --pat $HASURA_PAT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
on: | ||
pull_request: | ||
branches: | ||
- '**' | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install and Login to DDN CLI | ||
uses: hasura/[email protected] | ||
with: | ||
hasura-pat: ${{ secrets.HASURA_PAT }} | ||
|
||
- name: Deploy connectors from analytics subgraph | ||
run: ddn connector build create --connector analytics/connector/clickhouse/connector.cloud.yaml --target-supergraph supergraph.cloud.yaml --target-connector-link clickhouse | ||
|
||
- name: Deploy pg connector from experience subgraph | ||
run: ddn connector build create --connector experience/connector/pg/connector.cloud.yaml --target-supergraph supergraph.cloud.yaml --target-connector-link pg | ||
|
||
- name: Deploy mongo connector from experience subgraph | ||
run: ddn connector build create --connector experience/connector/mongo/connector.cloud.yaml --target-supergraph supergraph.cloud.yaml --target-connector-link mongo | ||
|
||
- name: Deploy connectors from sales subgraph | ||
run: ddn connector build create --connector sales/connector/pg/connector.cloud.yaml --target-supergraph supergraph.cloud.yaml --target-connector-link pg | ||
|
||
- name: Deploy connectors from sales subgraph | ||
run: ddn connector build create --connector sales/connector/ts/connector.cloud.yaml --target-supergraph supergraph.cloud.yaml --target-connector-link ts | ||
|
||
- name: Deploy connectors from users subgraph | ||
run: ddn connector build create --connector users/connector/user_pg/connector.cloud.yaml --target-supergraph supergraph.cloud.yaml --target-connector-link user_pg | ||
|
||
- name: Deploy supergraph | ||
run: ddn supergraph build create --supergraph supergraph.cloud.yaml | ||
|
||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y jq | ||
- name: Build and deploy TS functions and update the connector link | ||
run: ddn supergraph build create --supergraph ./supergraph.cloud.yaml --description "Build for commit ${{ github.sha }}" --out=json > build_output.json | ||
|
||
- name: Extract URLs from JSON | ||
id: extract_urls | ||
run: | | ||
BUILD_URL=$(jq -r '.build_url' build_output.json) | ||
CONSOLE_URL=$(jq -r '.console_url' build_output.json) | ||
echo "::set-output name=build_url::$BUILD_URL" | ||
echo "::set-output name=console_url::$CONSOLE_URL" | ||
- name: Add PR comment with build details | ||
if: github.event_name == 'pull_request' | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const buildUrl = '${{ steps.extract_urls.outputs.build_url }}'; | ||
const consoleUrl = '${{ steps.extract_urls.outputs.console_url }}'; | ||
const prNumber = context.payload.pull_request.number; | ||
const commitId = context.sha; | ||
await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: prNumber, | ||
body: `Supergraph build was successful! 🎉\n\n**Build URL:** [${buildUrl}](${buildUrl})\n**Console URL:** [${consoleUrl}](${consoleUrl})\n**Commit ID:** ${commitId}` | ||
}); | ||
github-token: ${{ secrets.GITHUB_TOKEN }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
context: | ||
supergraph: ../supergraph.yaml | ||
project: touched-mudfish-2410 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"recommendations": [ | ||
"HasuraHQ.hasura" | ||
] | ||
} | ||
"recommendations": [ | ||
"HasuraHQ.hasura" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"request": "launch", | ||
"type": "node", | ||
"program": "${workspaceFolder}", | ||
"name": "DDN Watch", | ||
"preLaunchTask": "watch", | ||
"cwd": "${workspaceFolder}" | ||
} | ||
] | ||
} | ||
"configurations": [ | ||
{ | ||
"cwd": "${workspaceFolder}", | ||
"name": "DDN Dev", | ||
"preLaunchTask": "dev", | ||
"program": "${workspaceFolder}", | ||
"request": "launch", | ||
"type": "node" | ||
} | ||
], | ||
"version": "0.2.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "watch", | ||
"type": "shell", | ||
"command": "ddn", | ||
"args": [ | ||
"watch", | ||
"--dir", | ||
"." | ||
], | ||
"problemMatcher": [], | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "new", | ||
"focus": true, | ||
"close": false, | ||
"clear": true | ||
}, | ||
"options": { | ||
"cwd": "${workspaceFolder}" | ||
} | ||
} | ||
] | ||
} | ||
"tasks": [ | ||
{ | ||
"args": [ | ||
"watch", | ||
"--dir", | ||
"." | ||
], | ||
"command": "ddn", | ||
"label": "watch", | ||
"options": { | ||
"cwd": "${workspaceFolder}" | ||
}, | ||
"presentation": { | ||
"clear": true, | ||
"close": false, | ||
"focus": true, | ||
"panel": "new", | ||
"reveal": "always" | ||
}, | ||
"problemMatcher": [], | ||
"type": "shell" | ||
} | ||
], | ||
"version": "2.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
const mdContent = ` | ||
|
||
# Quickstart with GitHub Codespaces | ||
|
||
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/soorajshankar/ecommerce_codespace_test) | ||
|
||
## Steps | ||
|
||
1. **Provide the Hasura PAT as a secret** | ||
|
||
- When prompted, enter the Hasura PAT (Personal Access Token) as a secret. | ||
- ![Codespace](images/codespace.png) | ||
|
||
2. **Start the engine and connector services** | ||
|
||
- Open a new terminal in the codespace. | ||
- Run the following command to start the Docker services: | ||
|
||
```bash | ||
HASURA_DDN_PAT=$(ddn auth print-pat) docker compose -f docker-compose.hasura.yaml up | ||
``` | ||
|
||
- This will start the necessary Docker services for the Hasura engine and connectors. | ||
- ![alt text](images/ports.png) | ||
|
||
3. **Start the TypeScript function runtime** | ||
|
||
- Open a new terminal in the codespace. | ||
- Navigate to the TypeScript connector directory: | ||
|
||
```bash | ||
cd sales/connector/ts | ||
``` | ||
|
||
- Install the dependencies: | ||
|
||
```bash | ||
npm install | ||
``` | ||
|
||
- Start the TypeScript function runtime: | ||
|
||
```bash | ||
npx dotenv -e .env.local -- npm run watch | ||
``` | ||
|
||
4. **Access the Hasura Console** | ||
|
||
- Update the port visibility for port 3000 to `PUBLIC` to access the Hasura Console. (without this you may access the URL that maps to port 3000 and try out queries, but we recommend you to use Hasura console for superior DX) | ||
- ![alt text](images/port_visibility.png) | ||
- Open the Hasura Console using the following URL: | ||
|
||
``` | ||
https://console.hasura.io/local/graphql?url=https://<your-github-app-url>.app.github.dev/ | ||
``` | ||
|
||
- You can now test the GraphQL API queries from the [Composability folder](https://github.com/hasura/ddn_beta_ecommerce/tree/main/Composability). | ||
|
||
- For example, to test the [AuthZ query](https://github.com/hasura/ddn_beta_ecommerce/blob/main/Composability/authZ.graphQL): | ||
- Set `x-hasura-role = customer` and `x-hasura-user-id = some_user_id` in the request headers. | ||
- Run the AuthZ query in the Hasura Console. | ||
|
||
## Making Changes | ||
|
||
After making changes to the Hasura configuration, you can rebuild the engine by executing the following command without restarting or rebuilding the Docker services. Docker's watch mode will automatically restart the engine with the new configuration: | ||
|
||
```bash | ||
ddn supergraph build local --output-dir ./engine | ||
``` | ||
|
||
This quickstart guide provides a step-by-step process for setting up and running the Hasura DDN starter kit using GitHub Codespaces, allowing you to quickly start developing your ecommerce solution. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ query ClickhouseJoin { | |
createdAt | ||
favoriteArtist | ||
user_id | ||
id | ||
isEmailVerified | ||
lastSeen | ||
name | ||
|
Oops, something went wrong.