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 @@ -5,6 +5,11 @@ namespace HotChocolate.Fusion.Options;
/// </summary>
public sealed class SourceSchemaPreprocessorOptions
{
/// <summary>
/// Enables schema validation when preprocessing source schemas.
/// </summary>
public bool EnableSchemaValidation { get; set; } = true;

/// <summary>
/// A list of tags used to exclude type system members from composition.
/// Any members annotated with these tags will be excluded.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ public CompositionResult Preprocess()
}

// Additional schema validation will catch issues introduced during preprocessing.
var validationLog = new ValidationLog();
if (!new SchemaValidator().Validate(schema, validationLog) && validationLog.HasErrors)
if (_options.EnableSchemaValidation)
{
log.WriteValidationLog(validationLog, schema);
var validationLog = new ValidationLog();
if (!new SchemaValidator().Validate(schema, validationLog) && validationLog.HasErrors)
{
log.WriteValidationLog(validationLog, schema);
}
}

return log.HasErrors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ private SourceSchemaPreprocessorOptions ToOptions()
{
var preprocessorOptions = new SourceSchemaPreprocessorOptions();

if (preprocessorSettings.EnableSchemaValidation is { } enableSchemaValidation)
{
preprocessorOptions.EnableSchemaValidation = enableSchemaValidation;
}

if (preprocessorSettings.InferKeysFromLookups is { } inferKeys)
{
preprocessorOptions.InferKeysFromLookups = inferKeys;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ internal sealed record ParserSettings

internal sealed record PreprocessorSettings
{
public bool? EnableSchemaValidation { get; init; }

public bool? InferKeysFromLookups { get; init; }

public bool? InheritInterfaceKeys { get; init; }
Expand Down
Loading