graphql-dotnet/graphql-dotnet

Deprecated input fields break the schema in 7.4.0

gao-artur opened this issue · 3 comments

Related issue #3658.

I'm upgrading from 7.3.0 to 7.7.1.
We have a few input types with all fields marked as deprecated. With a new version, I'm getting the following error even when schema.Features.DeprecationOfInputValues = false;

{
"error": "Invalid schema Error:\nInput Object type ContentRecordsQueryParams must define one or more fields."
}

With this config key set to false (default), I expect the field depreciation will be ignored, just like it was in the older version, but instead, the field is deprecated and not returned from the introspection query and breaks previously valid graph type.

As a workaround, I'm currently removing the depreciation reason from the input fields with the schema visitor:

internal class InputFieldsUnDeprecationVisitor : BaseSchemaNodeVisitor
{
    public override void VisitInputObjectFieldDefinition(FieldType field, IInputObjectGraphType type, ISchema schema)
    {
        field.DeprecationReason = null;
    }
}

So should we change the code so that it acts as though it was not deprecated when the feature is off?

Yes, I believe so. Moreover migration notes say

Since this feature may be potentially breaking for your app, clients or tooling it was done as opt-in. Either set schema.Features.DeprecationOfInputValues = true; or call schema.EnableExperimentalIntrospectionFeatures() method before initializing a schema.

This flag should fully disable this feature.