Load tester to simulate graphql based api (works only with Apollo queries). Senarios can be used to simulate user behaviours.

Usage no npm install needed!

<script type="module">
  import gqlLoadTester from '';


Load tester to simulate graphql based api (currently only works with Apollo graphql queries). Scenarios can be used to simulate user behaviours.


  npm i gql-load-tester
  yarn add gql-load-tester

using ts-node is advised (

 npm install -g typescript
 npm install -g ts-node

Its also possible to run it with node js (not fully tested).


  • Create a .ts file.
  • import and run the LoadTester function and your queries (assuming they are written in typescript).
  • run ts-node <your .ts file>.

(the process should be similar when using node and using a .js file)


interface ILoadTester {
    apolloConfig: ApolloConfig, // Check apollo client config
    duration?: number; // in seconds, specified how long the test should run.
                       // If a scenario completes before the duration ends, the scenario will be repeated
                       // Not specifying duration will run the users only once
    scenario: Scenario;
    parallelUsers: number; // number of users running a Scenario at any point in time

interface Scenario {
    initialPollingQueries?: PollingQuery[]
    steps: Step[];

interface Step { // Steps for the scenario, each step is carried out sequentially
    query?: Query,
    mutation?: Mutation,
    pollingQuery?: PollingQuery[], // polling queries can also be started during a step
    name: string;

interface PollingQuery extends Query{
    timer: number // milliseconds


import {gql} from '@apollo/client';

const APP_VERSION_QUERY = gql` // example query
  query version($os: String) {
    version(os: $os) {

export const PROFILE_QUERY = gql`  // example query
  query profile {

        apolloConfig : {
          uri: '<Your Server Url>',
          headers: { authorization: `Bearer XXXX`}
        parallelUsers: 20,
        duration: 20,
              name: 'Profile',
              query: {
                 query: PROFILE_QUERY
             name: 'AppVersion Query', 
             query: {
                   query: APP_VERSION_QUERY, variables: {os: 'ios'}