How to set the Field complexity in ComplexityValidationRule with v8? #4069
-
In v7, this is how we set the
Will the correct migration path be this?
Also, when migration the |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 19 replies
-
To use the old validation rule (to be removed in v9): .Concat(context.RequestServices.GetServices<IValidationRule>())
.Append(new LegacyComplexityValidationRule(new LegacyComplexityConfiguration
{
MaxDepth = _settings.MaxDepth,
MaxComplexity = _settings.MaxComplexity,
FieldImpact = _settings.FieldImpact
})); The new validation rule computes complexity and depth quite differently and has three different default values:
Please read https://graphql-dotnet.github.io/docs/guides/complexity-analyzer/ for details on how the complexity is computed, explaining how you may wish to set these defaults. For instance, perhaps this is most useful: .Concat(context.RequestServices.GetServices<IValidationRule>())
.Append(new ComplexityValidationRule(new ComplexityOptions
{
MaxDepth = _settings.MaxDepth,
MaxComplexity = _settings.MaxComplexity,
DefaultObjectImpact = _settings.FieldImpact ?? 1,
})); I do not have an equivalent |
Beta Was this translation helpful? Give feedback.
-
yes, it would become |
Beta Was this translation helpful? Give feedback.
-
@Shane32 thank you for your feedback! I am trying to upgrade OrchardCore to use version 8.0.2 from 7.8.0. Running into an issue and not sure if you have any insight. Couple of my unit tests are failing with the following exception:
As far as I can tell, this is the method that provides the schema Here is where the filter fields Perhaps something else changes iv v8 that is causing this issue. Any clues you may be able to share? The |
Beta Was this translation helpful? Give feedback.
-
Glad it's working! Open another issue if you have further questions. |
Beta Was this translation helpful? Give feedback.
In
MenuItemContentTypeBuilder
you are creating the class directly:whereas in
MenuItemInterface
you are not:So the schema builder is asked to initialize an instance itself + use an already initialized instance, which is not allowed.
The easiest solution is likely to comment out the first reference, as you already have the type specified, letting the schema builder create a single instance itself: