Extend OpenApi handler functionalities #1425
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR exposes
genericPayloadArgName
andselectQueryOrMutationField
from OpenAPI-to-GraphQL handler through Mesh YAML config.When true,
genericPayloadArgName
, allows setting argument name for mutation payload torequestBody
. If false current behavior will continue to have default camelCased pathname.This can really help when dealing with APIs that infer long classes names that make arguments required in GraphQL queries unreadable and so unfriendly as well.
Ultimately it can be helpful and seen as an alternative solution to #1422.
selectQueryOrMutationField
is the thing any OpenApi user needs.It allows to explicitly override GET/POST operations from Query to Mutation and vice versa; it effectively addresses #1113.
The current API for this is probably not the nicest but it works as follows:
In the future, this can be extracted to a transform plugin and ideally, we can automatically infer the OAS title rather than forcing users to specify that.
I added types and documentation and cannot wait for this to be released!
As a side note, I didn't enjoy the fact that the JSON schema and TypeScript interfaces are automatically generated from a GraphQL
yaml-config.graphql
schema.In this PR, for instance, this forced me to have a type
any
for the newly introducedselectQueryOrMutationField
; whilst with typescript I could have written a more accurate interface like below: