I'm not sure if you are facing the same problem as I did, but I had this issue when I was trying to use Ulid
type for IDs.
After an hour of debugging I found out that HotChocolate automatically creates lots of Id serializers, but they do not provide Ulid
ID serializer.
But you can register yours:
using System.Diagnostics.CodeAnalysis;
namespace SocialMediaMonitor.GraphQL.Types;
internal sealed class UlidNodeIdValueSerializer: INodeIdValueSerializer
{
public bool IsSupported(Type type) => type == typeof(Ulid) || type == typeof(Ulid?);
public NodeIdFormatterResult Format(Span<byte> buffer, object value, out int written)
{
if (value is Ulid u)
{
return System.Text.Encoding.UTF8.TryGetBytes(u.ToString(), buffer, out written)
? NodeIdFormatterResult.Success
: NodeIdFormatterResult.BufferTooSmall;
}
written = 0;
return NodeIdFormatterResult.InvalidValue;
}
public bool TryParse(ReadOnlySpan<byte> buffer, [NotNullWhen(true)] out object? value)
{
var conversion = Ulid.TryParse(buffer, out var result);
value = result;
return conversion;
}
}
builder.Services.AddSingleton<INodeIdValueSerializer>(sp => new UlidNodeIdValueSerializer());
Hope it will help!