graphql hotchoc using ResolveWith

 

Using resolveWith might be a good use-case for you. You can use it with the following code example, 



// setting up and using resolver
builder.Services.AddGraphQLServer().AddQueryType<FooQueryType>();
// another class - wiring up
public class FooQueryType : ObjectType
{
protected override void Configure(IObjectTypeDescriptor descriptor)
{
descriptor
.Field("foo")
.Argument("arg", a => a.Type<NonNullType<StringType>>())
.ResolveWith<FooResolvers>(r => r.GetFoo(default));
}
}
// Then you have your resolvers
public class FooResolvers
{
public string GetFoo(string arg)
{
return "magicfoo";
}
}
}

Then to run your query 

query {
   foo(arg:"")  
}



Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20