Here is the code that I am using to fetch ByteArrayContent type:
public class ImageDTO : APIResult
{
public byte[] ImageData
{
get;
set;
}
public string ImageFormat
{
get;
set;
}
public ImageDTO()
{
ImageData = new byte[]{};
}
}
public class ImageType : ObjectGraphType<ImageDTO>, IGraphQLType
{
public ImageType()
{
Field(img => img.ImageData);
Field(img => img.ImageFormat);
}
}
public class ImageResolver : Resolver, IImageResolver
{
private readonly ICommonService _commonService;
public ImageResolver(ICommonService commonService)
{
_commonService = commonService;
}
public void Resolve(GraphQLQuery graphQLQuery)
{
graphQLQuery.Field<ResponseGraphType<ImageType>>("imageresponse", arguments: new QueryArguments(new QueryArgument<NonNullGraphType<StringGraphType>>{Name = "imageId", Description = "id of the project"}), resolve: context =>
{
var imageId = context.GetArgument<string>("imageId");
var imageResult = _commonService.GetImage(imageId);
if (imageResult == null)
{
return NotFoundError(imageId);
}
return Response(imageResult);
}
);
}
}
On executing the above code I am getting the below mentioned error. The type: Byte cannot be coerced effectively to a GraphQL type\r\nParameter name: type\r\n at Type GraphQL.
From the link : https://github.com/graphql-dotnet/graphql-dotnet/issues/458 , it is mentioned that ByteGraphType is supported. I am using GraphQL.net nuget package with version:2.3.0 . So I believe it should support the ByteGraphType.
Can you please help me here to know how to fix this issue.