Skip to content

docs: fix stale API references in relay.md#10105

Open
PHILLIPS71 wants to merge 8 commits into
ChilliCream:mainfrom
PHILLIPS71:jp/stale-relay-docs
Open

docs: fix stale API references in relay.md#10105
PHILLIPS71 wants to merge 8 commits into
ChilliCream:mainfrom
PHILLIPS71:jp/stale-relay-docs

Conversation

@PHILLIPS71

Copy link
Copy Markdown
Contributor

What's wrong

IIdSerializer doesn't exist anymore. It was removed in df07a9169 (#7026, "Added new node id serializer.", April 2024) along with IdSerializer, IdMiddleware, and IdValue, and replaced with INodeIdSerializer.

INodeIdSerializer also has a different shape than the old interface. It's Format(string typeName, object internalId), not Serialize(schemaName, typeName, id):

src/HotChocolate/Core/src/Types/Types/Relay/Serialization/INodeIdSerializer.cs:6-20

public interface INodeIdSerializer
{
    string Format(string typeName, object internalId);
    ...
}

The old three-argument Serialize(null, "Product", productId) call has no direct equivalent, Format drops the schema name entirely.

While I was in there I checked the rest of the page against source and found three more things that had drifted:

  1. AddQueryFieldToMutationPayloads generates query: Query!, not query: Query. The field is non-null:

    src/HotChocolate/Core/src/Types/Types/Relay/QueryFieldTypeInterceptor.cs:44-49

    var queryFieldType = TypeReference.Parse($"{_queryType.Name}!");
  2. The predicate example called .Value on a plain string. MutationPayloadPredicate is Func<ITypeDefinition, bool>, and Name on ITypeDefinition is just a string. The framework's own default predicate shows the right usage:

    src/HotChocolate/Core/src/Types/Types/Relay/MutationPayloadOptions.cs:17-18

    public Func<ITypeDefinition, bool> MutationPayloadPredicate { get; set; } =
        type => type.Name.EndsWith("Payload", StringComparison.Ordinal);
  3. The NodeIdValueSerializer source generator doesn't fire automatically. The doc implied it kicks in whenever you use [ID] on a custom type. It actually only triggers on an explicit call to AddNodeIdValueSerializerFrom<T>():

    src/HotChocolate/Core/src/Types.Analyzers/Inspectors/NodeIdValueSerializerInspector.cs:19-29

@github-actions github-actions Bot added the 📚 documentation This issue is about working on our documentation. label Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📚 documentation This issue is about working on our documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants