Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

Locust GraphQL client GraphQL. This is a GraphQLLocust equivalent of HttpLocust

Project description

GraphQL Client for Locust

Locust is a python performance test library. Locust supports http client out of the box. This library provides the GraphQL Client for Locust.

This GraphQL Client is based on Prisma's Simple GraphQL Client for Python (


class GraphQLClient:
 def execute(self, label, query, variables=None, type ='graphql'):


  • type = Locust Request Type. Default value is 'graphql'
  • label = Locust Name
  • query = GraphQL Query
  • variables = GraphQL Variables. Default value is None


from locust import HttpLocust, TaskSet, task
from locustgraphqlclient import GraphQLLocust

class UserBehavior(TaskSet):
    def on_start(self):
        """ on_start is called when a Locust start before any task is scheduled """

    def on_stop(self):
        """ on_stop is called when the TaskSet is stopping """

    def login(self):
        query = '''
        mutation login($username: String!, $password: String!) {
          login(username: $username, password: $password) {
        variables = {
            'username': 'gm',
            'password': 'centric8'
        result = self.client.execute("login", query, variables)

        # Inject the Access Token in the Client, so subsequent requests can be made

    def logout(self):
        # Reset the Access Token in the Client, so no subsequent requests can be made

    def index(self):
        query = '''
                    query products {
                      products {
        result = self.client.execute("products", query)

    def profile(self):
        query = '''
                    query me {
                      me {
        result = self.client.execute("me", query)

class WebsiteUser(GraphQLLocust):
    task_set = UserBehavior
    min_wait = 5000
    max_wait = 9000

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for locust-graphql-client, version 0.3.4
Filename, size File type Python version Upload date Hashes
Filename, size locust-graphql-client-0.3.4.tar.gz (2.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page