Skip to content

Instantly share code, notes, and snippets.

@sonufrienko
Last active July 19, 2022 04:52
Show Gist options
  • Save sonufrienko/4354a67b59987086c95bd252d5580a66 to your computer and use it in GitHub Desktop.
Save sonufrienko/4354a67b59987086c95bd252d5580a66 to your computer and use it in GitHub Desktop.

Revisions

  1. sonufrienko revised this gist Jul 19, 2022. 2 changed files with 12 additions and 15 deletions.
    11 changes: 11 additions & 0 deletions graphql-load-testing.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    ## Basic use

    ```
    wrk -c <user-count> -t <cpu-core-count> -d 10 --latency https://your-server/endpoint
    ```

    ## GraphQL API

    ```
    wrk -s script.lua https://your-server/api/graphql
    ```
    16 changes: 1 addition & 15 deletions gistfile1.txt → script.lua
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,3 @@
    # Basic use

    ```
    wrk -c <user-count> -t <cpu-core-count> -d 10 --latency https://your-server/endpoint
    ```

    # GraphQL API

    ```
    wrk -s script.lua https://your-server/api/graphql
    ```

    ```lua
    wrk.method = "POST"
    wrk.headers["Content-Type"] = "application/json"
    wrk.headers["Accept"] = "application/json"
    @@ -28,5 +15,4 @@ query = [[
    variables = [[
    "ids": [1,2,3,4]
    ]]
    wrk.body ='{"query": "' .. string.gsub(query, '\n', '') .. '", "variables": {' .. string.gsub(variables, '\n', '') .. '} }'
    ```
    wrk.body ='{"query": "' .. string.gsub(query, '\n', '') .. '", "variables": {' .. string.gsub(variables, '\n', '') .. '} }'
  2. sonufrienko created this gist Jul 19, 2022.
    32 changes: 32 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    # Basic use

    ```
    wrk -c <user-count> -t <cpu-core-count> -d 10 --latency https://your-server/endpoint
    ```

    # GraphQL API

    ```
    wrk -s script.lua https://your-server/api/graphql
    ```

    ```lua
    wrk.method = "POST"
    wrk.headers["Content-Type"] = "application/json"
    wrk.headers["Accept"] = "application/json"

    query = [[
    query books($ids: [Integer]) {
    books(ids: $ids) {
    id
    name
    price
    }
    }
    }
    ]]
    variables = [[
    "ids": [1,2,3,4]
    ]]
    wrk.body ='{"query": "' .. string.gsub(query, '\n', '') .. '", "variables": {' .. string.gsub(variables, '\n', '') .. '} }'
    ```