-
Notifications
You must be signed in to change notification settings - Fork 348
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
Field Argument Type Rewriter Transform #3960
Comments
My use case: adding a required argument for all operations to context. I'd like to be able to state that a required argument is optional so that the value doesn't have to be passed in as a variable to the hooks, but is pulled from context in the resolver. |
Instead of a transform, you can add a new field and use type Query {
foo(id: ID!): Foo
} Then you add the following; extend type Query {
myFoo: Foo @resolveTo(
sourceName: "FOO_SOURCE" # Which source does the target field belong to?
sourceTypeName: "Query", # Which root type does the target field belong to?
sourceFieldName: "foo", # What is the source field name?
sourceArgs: { # What args the source field does need?
id: "{context.myFooId}"
}
)
} |
@ardatan Thank you for the response and the example. I'm concerned that this approach would be rather cumbersome to migrate to and maintain. Ideally, I want to be able to configure, in a declarative way, "for every argument fooId, resolve to context fooId". |
It would be very helpful to additional transforms for field arguments. Currently only argument renaming is supported, but not argument retyping.
An alternative solution is what this repo offers https://github.com/graphql-query-rewriter/core. But it is much more limited to graphql-mesh since it only offers field argument rewriting. And it wouldn't be very clean to use it in conjunction with graphql-mesh.
A proposed solution would be to add an experimental field argument type transform that leverages this alternative pkg, or maybe extend the rename tool to also be able to change argument types.
The text was updated successfully, but these errors were encountered: