Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public static IRequestExecutorBuilder AddSourceSchemaDefaults(
o.ApplyShareableToPageInfo = true;
o.ApplyShareableToNodeFields = true;
o.ApplySerializeAsToScalars = true;
o.InferKeysFromLookups = true;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using HotChocolate.Fetching;
using HotChocolate.Language;
using HotChocolate.Resolvers;
using HotChocolate.Types.Composite;
using HotChocolate.Validation;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.ObjectPool;
Expand Down Expand Up @@ -144,6 +145,7 @@ private static DefaultRequestExecutorBuilder CreateBuilder(

builder.TryAddTypeInterceptor<DataLoaderRootFieldTypeInterceptor>();
builder.TryAddTypeInterceptor<RequirementsTypeInterceptor>();
builder.TryAddTypeInterceptor<SourceSchemaKeyInferenceTypeInterceptor>();

builder.AddDocumentCache();

Expand Down
6 changes: 6 additions & 0 deletions src/HotChocolate/Core/src/Types/IReadOnlySchemaOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,10 @@ public interface IReadOnlySchemaOptions
/// Applies the @serializeAs directive to scalar types that specify a serialization format.
/// </summary>
bool ApplySerializeAsToScalars { get; }

/// <summary>
/// Infers @key directives from the arguments of @lookup fields so that the published
/// source schema describes the entity keys that the lookups resolve.
/// </summary>
bool InferKeysFromLookups { get; }
}
6 changes: 5 additions & 1 deletion src/HotChocolate/Core/src/Types/SchemaOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ public int OperationDocumentCacheSize
/// <inheritdoc cref="IReadOnlySchemaOptions.ApplySerializeAsToScalars"/>
public bool ApplySerializeAsToScalars { get; set; }

/// <inheritdoc cref="IReadOnlySchemaOptions.InferKeysFromLookups"/>
public bool InferKeysFromLookups { get; set; }

/// <summary>
/// Creates a mutable options object from a read-only options object.
/// </summary>
Expand Down Expand Up @@ -238,6 +241,7 @@ public static SchemaOptions FromOptions(IReadOnlySchemaOptions options)
ApplyShareableToPageInfo = options.ApplyShareableToPageInfo,
ApplyShareableToConnections = options.ApplyShareableToConnections,
ApplyShareableToNodeFields = options.ApplyShareableToNodeFields,
ApplySerializeAsToScalars = options.ApplySerializeAsToScalars
ApplySerializeAsToScalars = options.ApplySerializeAsToScalars,
InferKeysFromLookups = options.InferKeysFromLookups
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace HotChocolate.Types.Composite;
/// an entity across different source schemas.
/// </para>
/// <para>
/// directive @key(fields: FieldSelectionSet!) on OBJECT | INTERFACE
/// directive @key(fields: FieldSelectionSet!) repeatable on OBJECT | INTERFACE
/// </para>
/// <para>
/// <see href="https://graphql.github.io/composite-schemas-spec/draft/#sec--key"/>
Expand All @@ -19,7 +19,7 @@ namespace HotChocolate.Types.Composite;
DirectiveNames.Key.Name,
DirectiveLocation.Object
| DirectiveLocation.Interface,
IsRepeatable = false)]
IsRepeatable = true)]
[GraphQLDescription(
"""
The @key directive is used to designate an entity's unique key,
Expand Down
Loading
Loading