-
Notifications
You must be signed in to change notification settings - Fork 3
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
Question on Deprecation of withRequestQueryAndVariables and Java Use #15
Comments
Hello, I'd like to provide some context on this deprecation. Wiremock operates both as a standalone application and as a library, requiring different implementation approaches for extensions. In standalone mode, you need to pass the extension's name and parameters, whereas in library mode, passing a class is possible. My thought is to unify these experiences, allowing developers to use the same API for extensions without worrying about the mode. The standalone API, which passes JSON via parameters, also works in library mode. Therefore, I'm leaning towards using it. (The deprecated methods are implemented for library mode.) I agree that manually assembling JSON can be cumbersome (thank you for pointing this out). Providing a Json Builder Class or a similar tool might be a good solution for resolving this issue. I would appreciate your thoughts on this matter. |
I definitely agree with your first point. We should unify the experience of using the extension to passing the extensions name and passing parameters. Custom matching document makes it sound like although passing a class is possible, that should really only be used for |
As to your second point, a builder could be nice, but in this situation it may be excessive when a single method might be enough. I will try out some things on my side and post back later with my thoughts. |
In the current implementation, the following code can be used for both Standalone and Library modes, as shown here: Client-Side Test Configuration. fun registerGraphQLWiremock(json: String) {
WireMock(8080).register(
post(urlPathEqualTo(endPoint))
.andMatching(GraphqlBodyMatcher.extensionName, GraphqlBodyMatcher.withRequest(json))
.willReturn(
aResponse()
.withStatus(200)
)
)
} This usage is similar to what we have in the wiremock-state-extension, as demonstrated in this example: StateRequestMatcherTest.java. The |
Summary
I would like to understand why the
withRequestQueryAndVariables
method is@Deprecated
. It feels strange that the recommended method for creating aGraphqlBodyMatcher
is to manually create the expectedJson each time.What I would expect as a user of the library is an easier (and less repetitive) way to create a
GraphqlBodyMatcher
. Also, it doesn't make sense to me that expectedJson doesn't need to be valid JSON (because newline characters are removed). For example, my IDE will get very mad about this, but it can be used to successfully create aGraphqlBodyMatcher
.References
30e722c
3f0dd56
The text was updated successfully, but these errors were encountered: