Skip to main content

Overview

LoadForge makes testing GraphQL APIs straightforward by utilizing standard HTTP POST requests to send GraphQL queries. This guide demonstrates how to create a load test to query the missions from the publicly available SpaceX GraphQL API. The examples provided here can be adapted to test any GraphQL API, including authentication scenarios.

Basic Example

Here’s a fundamental example showing a standard GraphQL query that requests the mission IDs and names from the SpaceX API:
The following example shows how to implement this query for use in a LoadForge test, demonstrating the straightforward integration of GraphQL queries.

Authenticating GraphQL Requests

Many GraphQL APIs require authentication. The following example shows how to set custom headers for authentication:
For dynamic authorization token retrieval, the on_start method can automate this process, ensuring all requests include the required authentication header:

Locust Test Script (locust.py)


LoadForge is built upon the robust foundation of Locust, which means that if you’re already a user of the open-source Locust tool, you can directly use this script in your tests. If you’re considering upgrading your testing capabilities, think about importing your Locust script to LoadForge and make the most out of your load testing efforts!