From d3dd6f7127175ca0fc900098f69c576faf262fee Mon Sep 17 00:00:00 2001 From: Stephen Spalding Date: Tue, 11 Jan 2022 23:15:35 -0800 Subject: [PATCH] Move deprecated validation to Section 3 (#922) --- spec/Section 3 -- Type System.md | 8 +++++--- spec/Section 5 -- Validation.md | 24 ------------------------ 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/spec/Section 3 -- Type System.md b/spec/Section 3 -- Type System.md index df6bc813f..7686db7c8 100644 --- a/spec/Section 3 -- Type System.md +++ b/spec/Section 3 -- Type System.md @@ -879,6 +879,8 @@ of rules must be adhered to by every Object type in a GraphQL schema. {"\_\_"} (two underscores). 2. The argument must accept a type where {IsInputType(argumentType)} returns {true}. + 3. If argument type is Non-Null and a default value is not defined: + - The `@deprecated` directive shall not be applied to this argument. 3. An object type may declare that it implements one or more unique interfaces. 4. An object type must be a super-set of all interfaces it implements: 1. Let this object type be {objectType}. @@ -1652,6 +1654,8 @@ input ExampleInputObject { {"\_\_"} (two underscores). 3. The input field must accept a type where {IsInputType(inputFieldType)} returns {true}. + 4. If input field type is Non-Null and a default value is not defined: + - The `@deprecated` directive shall not be applied to this input field. 3. If an Input Object references itself either directly or through referenced Input Objects, at least one of the fields in the chain of references must be either a nullable or a List type. @@ -2074,9 +2078,7 @@ type ExampleType { ``` The `@deprecated` directive must not appear on required (non-null without a -default) arguments or input object field definitions. Deprecated arguments and -fields are excluded by default in introspection, and deprecating required -arguments or input fields could create confusion for clients. +default) arguments or input object field definitions. ```graphql counter-example type ExampleType { diff --git a/spec/Section 5 -- Validation.md b/spec/Section 5 -- Validation.md index 076b55d2f..4eda8e7b4 100644 --- a/spec/Section 5 -- Validation.md +++ b/spec/Section 5 -- Validation.md @@ -736,7 +736,6 @@ invalid. - Let {argumentName} be the name of {argumentDefinition}. - Let {argument} be the argument in {arguments} named {argumentName} - {argument} must exist. - - {argument} must not be deprecated. - Let {value} be the value of {argument}. - {value} must not be the {null} literal. @@ -784,18 +783,6 @@ fragment missingRequiredArg on Arguments { } ``` -If an argument is required (non-null without a default value), it must not be -marked as deprecated. - -```graphql counter-example -type Query { - """ - This is invalid because the locale argument is both required and deprecated. - """ - myName(locale: String! @deprecated): String -} -``` - ## Fragments ### Fragment Declarations @@ -1409,7 +1396,6 @@ For example the following document will not pass validation. - Let {fieldName} be the name of {fieldDefinition}. - Let {field} be the input field in {fields} named {fieldName} - {field} must exist. - - {field} must not be deprecated. - Let {value} be the value of {field}. - {value} must not be the {null} literal. @@ -1420,16 +1406,6 @@ arguments, an input object may have required fields. An input field is required if it has a non-null type and does not have a default value. Otherwise, the input object field is optional. -A required input object field must not be marked as deprecated. - -```graphql counter-example -input Point { - x: Int! - y: Int! - z: Int! @deprecated(reason: "Northward, not upward") -} -``` - ## Directives ### Directives Are Defined