GraphQL and SOAP APIs send almost every call to one URL, and they fail in their own formats: GraphQL often answers
200 OK with an errors array, and SOAP answers a Fault envelope. A GraphQL or SOAP endpoint in Jitterbox is a
normal mock that also understands its protocol. It can:
- answer each operation differently, from one URL,
- read the request body the way the protocol shapes it (GraphQL variables, SOAP Body elements),
- return errors in the protocol's own format, including the failures that arrive as
200 OK.
1. Create the endpoint
In a project, create an endpoint and pick GraphQL or SOAP under Answers as.
| Type | Default path | Methods | Default response |
|---|---|---|---|
| GraphQL | /graphql |
POST (also GET or ANY for queries sent as ?query=) |
{"data": {...}} |
| SOAP | /soap (any path works) |
POST |
A SOAP 1.1 envelope |
Point your client at https://<projectKey>.jitterbox.dev/graphql (or your SOAP path). Through the API, set kind to
GRAPHQL or SOAP. All other fields are the same as for a static endpoint.
2. Answer per operation
Every request gets the endpoint's response, unless a rule on the Rules tab matches first. Rules can use the operation condition:
- GraphQL: the request's
operationName. If the request doesn't send one, the name of the operation in the document (query GetUser { … }). If the operation has no name either, its first root field ({ viewer { … } }givesviewer). Requests that send several queries in one batch are matched on the first one. - SOAP: the local name of the first element inside
<Body>(<m:GetUser>givesGetUser). If the body can't be parsed, the last segment of theSOAPActionheader or of theactionparameter of theContent-Type.
{
"name": "Users API",
"method": "POST",
"pathPattern": "/graphql",
"kind": "GRAPHQL",
"responseStatus": 200,
"responseBody": "{\"data\":{\"viewer\":{\"id\":\"1\"}}}",
"conditionalResponses": [{
"name": "GetUser",
"conditions": [{ "source": "OPERATION", "op": "EQUALS" , "value": "GetUser" }],
"status": 200,
"template": true,
"body": "{\"data\":{\"user\":{\"id\":\"{{ body.variables.id }}\"}}}"
}]
}
How each protocol's body looks to body field conditions and to {{ body.… }} templates:
- GraphQL: the request JSON. Use
variables.id,operationNameorquery. GET requests are read from?query=,?operationName=and?variables=and look the same. - SOAP: the contents of
<Body>, with each element under its local name. Namespaces are dropped, attributes become@name, and elements that repeat become arrays.<m:GetUser><m:userId>42</m:userId></m:GetUser>is read asGetUser.userId=42.
{{ operation }} inserts the operation name. On SOAP endpoints, the response's Content-Type follows the SOAP version
of the request (text/xml for 1.1, application/soap+xml for 1.2), unless you set one.
The request inspector shows the operation of each request.
3. Add failures
All the usual faults work. On these endpoints, errors come back in the protocol's own format:
| Fault | GraphQL | SOAP |
|---|---|---|
| HTTP error (no custom body) | {"errors":[{"message":…,"extensions":{"code":"RATE_LIMITED"}}]} with the status you chose. The code depends on the status: 401 UNAUTHENTICATED, 403 FORBIDDEN, 429 RATE_LIMITED, 503 SERVICE_UNAVAILABLE, other 5xx INTERNAL_SERVER_ERROR. |
A Fault in the request's SOAP version: Client/Sender for 4xx, Server/Receiver for 5xx. |
| Malformed response, invalid body | Broken JSON | Broken XML (the root element is never closed) |
| GraphQL error | 200 OK with errors[0].extensions.code set to the code you chose. Without partial, data is null. With partial, your response's data is kept and only the field at path (default: the first field) is set to null, with a matching errors[0].path. This is how one failing resolver looks. |
Skipped; the inspector says why |
| SOAP fault | Skipped; the inspector says why | A Fault envelope with your code, fault string and optional XML detail. The code is renamed to fit the version (Client in 1.1 is Sender in 1.2). The status is HTTP 500, or 400 for a SOAP 1.2 Sender fault, unless you set one. |
An HTTP error beats a GraphQL error or SOAP fault when both fire. A custom body on an HTTP error rule is sent as is.
GraphQL error codes worth testing:
UNAUTHENTICATED: does your client refresh the session or sign the user out?RATE_LIMITED: some APIs throttle with200 OK. Does your client still back off?PERSISTED_QUERY_NOT_FOUND: an Apollo client using automatic persisted queries should send the request again with the full query. Jitterbox records both attempts.INTERNAL_SERVER_ERRORwith partial: does your UI render the rest of the data, or blank out the whole screen?
Presets in the scenario editor, offered once a project has a GraphQL or SOAP endpoint: Partial failure, Session expired, Persisted query miss (GraphQL); Server faults, Fail twice, then succeed (SOAP).
Force a fault from a single request with the X-Jitterbox-Fault header:
curl https://<projectKey>.jitterbox.dev/graphql -H 'X-Jitterbox-Fault: graphql_error=UNAUTHENTICATED' \
-H 'Content-Type: application/json' -d '{"query":"{ viewer { id } }"}'
curl https://<projectKey>.jitterbox.dev/soap -H 'X-Jitterbox-Fault: soap_fault=Client' \
-H 'Content-Type: text/xml' -d @request.xml
Limits
- Jitterbox reads the GraphQL document only to find the operation. It doesn't validate queries against a schema, and the response doesn't change with the fields the client asked for. Use rules per operation for that.
- SOAP requests are parsed with DTDs disabled, so entity tricks (XXE) don't work and such a request has no Body to read.
Its operation can still come from
SOAPAction. - WSDL import, GraphQL subscriptions and gRPC aren't supported yet.