Replies: 2 comments
-
I was also hoping to use this to make input object properties with nullable UUID/GUIDS not be Guid.Empty, and just be null like they used to. Pretty sure I won't be able to set the value to null though:
|
Beta Was this translation helpful? Give feedback.
-
In v13 this is a bit more conventient as you can also call I agree, the argument value is a bit hard to construct when you do not know the internals. But essentially, Here is a simple example: public class QueryType : ObjectType
{
protected override void Configure(IObjectTypeDescriptor descriptor)
{
descriptor
.Field("callback")
.Argument("lang", t => t.Type<StringType>())
.Use(next => ctx =>
{
ctx.ReplaceArgument(
"lang",
new ArgumentValue(
ctx.Selection.Field.Arguments["lang"],
ValueKind.String,
true,
false,
"replacedValue",
new StringValueNode("replacedValue")
));
return next(ctx);
})
.Type<StringType>()
.Resolve(c => c.ArgumentValue<string>("lang")); // read the argument, return the value
}
} The query query {
callback(lang: "input")
} returns now {
"data": {
"callback": "replacedValue"
}
} |
Beta Was this translation helpful? Give feedback.
-
I need to potentially make changes to input data for mutations. I've been down about half a dozen rabbit holes trying to figure out how this might get solved. Then I discovered ReplaceArguments() that looks promising, but figuring out how to use it is damn near impossible.
It operates on ArgumentValue, and the constructor takes a bunch of arguments that basically is a crap-shoot if I get right.
The first argument is IInputFieldInfo; how do you get one of those? MiddlewareContext implements IMiddlewareContext and has an Arguments property. The problem is that it's not available since everything is internal.
In my field middleware, the only thing I seem to have is a bunch of ArgumentNodes accessible from IMiddlewareContext.Selection.SyntaxNode.Arguments. How do we convert these into an ArgumentValue?
The ArgumentValue also requires an IValueNode. Again, how do we create it?
Beta Was this translation helpful? Give feedback.
All reactions