Description
Is your feature request related to a problem? Please describe.
I am currently using graphql-mesh as a proxy in front of an hasura. Since the schema.graphql
is automatically generated by hasura API and sometimes mismatch what I would like to consume, it would be convenient to use the "replace-field" to "correct" the types of hasura.
Example:
type file {
# This type is automatically generated by Hasura as a parameterizable query returning an array
# Even if in code implementation, I do know this will always return an array of 1 element
last_version(order_by: ....): [file_version!]
}
## What I would like to replace it by
type file {
last_version: file_version!
}
Then into the resolver:
{
last_version: next => async (root, args, context, info) => {
// 'next' is the field resolve function
const last_version = await next(root, args, context, info);
return last_version[0];
}
}
Describe the solution you'd like
As for now, the "replace-field" transform, only work properly with the "bare" mode, which is incompatible with an "already graphql" API. It would be perfect if it work the same with "wrap" mode, or if we had an alternative to achieve what I want to do.
Describe alternatives you've considered
I've tried to check on additional-resolvers but they don't seem fit to my need.
Additional context
From my tests, for now, the "replace-field" transform works well with "graphql" API as long as the "schema types rewriting" goes (I've been able to replace the type of last_version
with the one I wanted). However, it does crash at runtime when trying to get the value.