Venabo GraphQL Templates
A simple JavaScript tool to run and test GraphQL queries against the Venabo API.
Features
- 🚀 Automatically discovers and runs all
.gqlfiles in the directory - ✅ Validates GraphQL queries and mutations
- 📊 Provides test results summary
- 🔍 Verbose mode for detailed output
- 🎨 Colorized terminal output
Setup
- Install dependencies:
yarn install
Usage
Run all tests
yarn test
Or directly:
node run-tests.js
Run with verbose output
yarn test:verbose
Or:
node run-tests.js --verbose
Custom GraphQL Endpoint
Set the GRAPHQL_ENDPOINT environment variable to use a different endpoint:
# 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:
# 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:
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
query {
getProducts(input: { take: 10 }) {
items {
id
identifierAlias: identifier
}
}
}
The tool will automatically:
- Discover all
.gqlfiles - 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 passed1- One or more tests failed