-
Notifications
You must be signed in to change notification settings - Fork 1
Java-friendly APIs for MockWebServer #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi 👋 Indeed, using If you really want to, you can get /**
* Because url doesn't suspend on the JVM, we can just use the return value
*/
String url = (String) mockServer.url(new Continuation<String>() {
@NotNull @Override public CoroutineContext getContext() {
return EmptyCoroutineContext.INSTANCE;
}
@Override public void resumeWith(@NotNull Object o) {
}
}); Or write a little bit of Kotlin code to bridge the suspend function (see this stackoverflow answer). All in all, for Java use cases, I would recommend using OkHttp MockWebServer. The main thing that the Apollo MockServer supports is multiplatform but if you're not using that, OkHttp MockWebServer should provide most of the API (and actually Apollo MockServer uses OkHttp MockWebServer under the hood) using a much more Java-friendly API. Hope this helps! |
I imported these in my spring boot project.
testImplementation project(":testing:unit-testing")
testImplementation("com.apollographql.apollo3:apollo-mockserver:3.3.0")
api "com.apollographql.apollo:apollo-runtime"
For example, when I want to create a MockResponse, there are no builder or set methods. I can only call get methods for these objects. Or when I want to set URL for MockServer, it gives this error
Required type: Continuation <? super java.lang.String>
Provided: String
I hope its not an obvious question. Am i importing something wrong? or I cannot those in Java anymore?
Thank you in advance!
The text was updated successfully, but these errors were encountered: