-
-
Notifications
You must be signed in to change notification settings - Fork 761
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
Bug: HC 14.0.0-p.98 prevents Relay IDs from working when a custom ID class or record is used #7098
Comments
Actually we now support a much better way to support these things ... you can now implement your own optimized value serializers for these. However, in the next couple of builds the source generator will also offer automatic generation of these. |
This shows the composite ID serializer .... graphql-platform/src/HotChocolate/Core/test/Types.Tests/Types/Relay/DefaultNodeIdSerializerTests.cs Line 270 in f7dfae1
these must be registered with AddNodeIdValueSerializer .... However ... with the next couple of builds there will be auto generation and auto registration. |
|
This appears to still be present in the latest of the 14.x line, even with |
I'm 100% confident that it works, because I migrated our custom Ids at work to the new serializers. |
You need to implement an internal sealed class ProductIdentifierNodeIdValueSerializer : CompositeNodeIdValueSerializer<ProductIdentifier> {
protected override NodeIdFormatterResult Format(Span<byte> buffer, ProductIdentifier value, out int written) {
if (TryFormatIdPart(buffer, value.Part1, out var writtenPart1Length)
&& TryFormatIdPart(buffer.Slice(writtenPart1Length), value.Part2, out var writtenPart2Length)) {
written = writtenPart1Length + writtenPart2Length;
return NodeIdFormatterResult.Success;
}
written = 0;
return NodeIdFormatterResult.BufferTooSmall;
}
protected override bool TryParse(ReadOnlySpan<byte> buffer, out ProductIdentifier value) {
if (/* your parsing logic */) {
// successfully parsed
value = parsedValue;
return true;
}
// failed to parse
return false;
}
} Then you need to register the serializer. private static IRequestExecutorBuilder AddStronglyTypedIds(
this IRequestExecutorBuilder builder) {
builder
.AddNodeIdValueSerializer<ProductIdentifierNodeIdValueSerializer>()
.BindRuntimeType<ProductIdentifier, IdType>();
} Hope this helps :) |
Product
Hot Chocolate
Version
14.0.0-p.98
Link to minimal reproduction
https://github.com/Jlopez2045/RelayCustomIdIssue
Steps to reproduce
Run following query:
What is expected?
What is actually happening?
Relevant log output
No response
Additional context
Upgraded from
14.0.0-p.82
The text was updated successfully, but these errors were encountered: