initial commit
This commit is contained in:
120
readme.md
Normal file
120
readme.md
Normal file
@@ -0,0 +1,120 @@
|
||||
# Venabo GraphQL Templates
|
||||
|
||||
A simple JavaScript tool to run and test GraphQL queries against the Venabo API.
|
||||
|
||||
## Features
|
||||
|
||||
- 🚀 Automatically discovers and runs all `.gql` files in the directory
|
||||
- ✅ Validates GraphQL queries and mutations
|
||||
- 📊 Provides test results summary
|
||||
- 🔍 Verbose mode for detailed output
|
||||
- 🎨 Colorized terminal output
|
||||
|
||||
## Setup
|
||||
|
||||
1. Install dependencies:
|
||||
```bash
|
||||
yarn install
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Run all tests
|
||||
```bash
|
||||
yarn test
|
||||
```
|
||||
|
||||
Or directly:
|
||||
```bash
|
||||
node run-tests.js
|
||||
```
|
||||
|
||||
### Run with verbose output
|
||||
```bash
|
||||
yarn test:verbose
|
||||
```
|
||||
|
||||
Or:
|
||||
```bash
|
||||
node run-tests.js --verbose
|
||||
```
|
||||
|
||||
### Custom GraphQL Endpoint
|
||||
|
||||
Set the `GRAPHQL_ENDPOINT` environment variable to use a different endpoint:
|
||||
|
||||
```bash
|
||||
# Windows PowerShell
|
||||
$env:GRAPHQL_ENDPOINT="https://your-endpoint.com/graphql"; node run-tests.js
|
||||
|
||||
# Windows CMD
|
||||
set GRAPHQL_ENDPOINT=https://your-endpoint.com/graphql && node run-tests.js
|
||||
|
||||
# Linux/Mac
|
||||
GRAPHQL_ENDPOINT=https://your-endpoint.com/graphql node run-tests.js
|
||||
```
|
||||
|
||||
Default endpoint: `https://venabo.phx-erp.cloud/backend-api/admin-api`
|
||||
|
||||
### Custom Authorization Token
|
||||
|
||||
Set the `AUTH_TOKEN` environment variable to use a different Bearer token:
|
||||
|
||||
```bash
|
||||
# Windows PowerShell
|
||||
$env:AUTH_TOKEN="your-token-here"; node run-tests.js
|
||||
|
||||
# Windows CMD
|
||||
set AUTH_TOKEN=your-token-here && node run-tests.js
|
||||
|
||||
# Linux/Mac
|
||||
AUTH_TOKEN=your-token-here node run-tests.js
|
||||
```
|
||||
|
||||
**Note:** All requests include an `Authorization: Bearer <token>` header.
|
||||
|
||||
### Using .env File
|
||||
|
||||
You can create a `.env` file in the project root to store your configuration:
|
||||
|
||||
```env
|
||||
GRAPHQL_ENDPOINT=https://venabo.phx-erp.cloud/backend-api/admin-api
|
||||
AUTH_TOKEN=your-token-here
|
||||
```
|
||||
|
||||
The `.env` file is automatically loaded when you run the tests. Environment variables set in your shell will override values in the `.env` file.
|
||||
|
||||
## Test Files
|
||||
|
||||
Create `.gql` files in the project directory. Each file should contain a valid GraphQL query, mutation, or subscription:
|
||||
|
||||
**Example: `Artikel.gql`**
|
||||
```graphql
|
||||
query {
|
||||
getProducts(input: { take: 10 }) {
|
||||
items {
|
||||
id
|
||||
identifierAlias: identifier
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The tool will automatically:
|
||||
- Discover all `.gql` files
|
||||
- Extract the query/mutation/subscription
|
||||
- Send it to the GraphQL endpoint
|
||||
- Report success or failure
|
||||
|
||||
## Output
|
||||
|
||||
The tool provides:
|
||||
- ✅ Success indicators for passing tests
|
||||
- ❌ Error messages for failing tests
|
||||
- 📊 Summary statistics at the end
|
||||
- 🔍 Detailed output in verbose mode (including query content and response data)
|
||||
|
||||
## Exit Codes
|
||||
|
||||
- `0` - All tests passed
|
||||
- `1` - One or more tests failed
|
||||
Reference in New Issue
Block a user