Apollo Kotlin MockServer Help

Recipes

Enqueue String responses

mockServer.enqueueString( string = "{\"status\":200}", contentType = "application/json" )

Enqueue Error responses

mockServer.enqueueError(500)

Enqueue Multipart responses

mockServer.enqueueMultipart( partsContentType = "application/json" ).apply { enqueuePart("{\"part\": 1}".toByteString(), isLast = false) enqueuePart("{\"part\": 2}".toByteString(), isLast = false) // There **must** be a last part enqueuePart("{\"part\": 3}".toByteString(), isLast = true) }

Add an artificial delay

// Wait 1s before returning the response mockServer.enqueue( MockResponse.Builder() .delayMillis(1000) .body("OK") .build() )
Last modified: 19 July 2024