import http from 'k6/http';
import { check } from 'k6';
export const options = { vus: 50, duration: '3m' };
const query = `
query GetProducts($limit: Int!) {
products(limit: $limit) {
id
name
price
reviews { rating }
}
}
`;
export default function () {
const res = http.post('https://api.example.com/graphql',
JSON.stringify({ query, variables: { limit: 20 } }),
{ headers: { 'Content-Type': 'application/json' } }
);
check(res, {
'status 200': (r) => r.status === 200,
'no errors': (r) => !JSON.parse(r.body).errors,
});
}k6 supports WebSocket connections, so you can test GraphQL subscriptions over WebSocket. Use the k6/ws module to establish and maintain subscription connections.
Create separate test scenarios with varying query depths and field selections. Use k6 stages to gradually increase complexity and VU count to find your server's limits.
Load test your REST and GraphQL APIs with up to 200 virtual users for free. Real-time metrics, JavaScript scripting, and instant results.
Load test WebSocket servers with hundreds of concurrent connections. Validate message throughput, latency, and connection stability.
Run HTTP load tests against any endpoint. Support for GET, POST, PUT, DELETE with custom headers and payloads. Free for up to 200 VUs.