Skip to main content

GraphQL Schema ([graphql])

When the protocol = "graphql" execution directive is specified at the root of your request file, Rumour unlocks the [graphql] structural block.

Unlike REST where the HTTP [body] is manually constructed, the [graphql] block natively parses, formats, and safely injects variables into a GraphQL-compliant JSON payload before dispatching it to the server.


Actionable Quickstart​

Want to test this schema right now? You can run it against the official rumour-mock-server repository.

1. Start the Mock Server​

In a new terminal window, boot up the multi-protocol mock server (provides a GraphQL endpoint on port 4000):

cd rumour-mock-server/mock-server
npm install
npm start

2. Scaffold a Workspace​

In your main terminal, initialize a fresh testing workspace:

mkdir try_graphql
cd try_graphql
rumour init
rumour new gql_tests

3. Create the Request File​

Paste this complete, runnable request into gql_tests/request.toml:

name = "quickstart_graphql"
protocol = "graphql"

[request]
method = "POST"
url = "http://localhost:4000/api/v2/graphql"

[graphql]
operation_name = "FetchActiveUsers"
query = '''
query FetchActiveUsers {
user(id: "u-101") { id }
}
'''

[assert]
status = 200
graphql_errors = false

4. Run the Test​

Execute the test and watch Rumour automatically parse, format, and assert the GraphQL payload!

rumour run gql_tests/ -v

Root Parameters​

FieldTypeRequiredDescription
queryStringYesThe raw GraphQL query or mutation string. Supports multi-line TOML strings (''').
operation_nameStringNoThe specific operation to execute if the query string contains multiple operations.

Example​

[graphql]
operation_name = "FetchActiveUsers"
query = '''
query FetchActiveUsers { users(status: "ACTIVE") { id } }
query FetchAllUsers { users { id status } }
'''

Variables ([graphql.variables])​

Instead of string-interpolating values directly into your query (which exposes you to injection vulnerabilities and formatting errors), you should use the [graphql.variables] table.

Rumour automatically serializes this TOML table into a JSON object and passes it alongside your query in the standard GraphQL format.

[graphql.variables]
organization_id = "org_123"
limit = 50
include_deleted = false

# You can even use Rumour's dynamic variables inside the GraphQL variables!
auth_token = "{{session_token}}"
tip

When passing complex structures, you can nest variables using TOML's dot-notation (e.g., [graphql.variables.filter]).


Apollo Extensions ([graphql.extensions])​

For advanced GraphQL servers (such as those using Apollo Server), you may need to pass an extensions object to leverage features like Persisted Queries or custom tracing.

The [graphql.extensions] block is serialized and attached to the root of the GraphQL payload.

[graphql.extensions.persistedQuery]
version = 1
sha256Hash = "ecf4edb46db40b5132295c02b37a4e005db3e4"

If you use Persisted Queries, you can completely omit the query string from the [graphql] block, and Rumour will just send the extensions and variables!