Add @deprecated
directive
This commit is contained in:
parent
84350bfb0f
commit
e6b2e57db8
3 changed files with 102 additions and 0 deletions
|
@ -85,10 +85,14 @@ pub enum DirectiveLocation {
|
||||||
Scalar,
|
Scalar,
|
||||||
#[graphql(name = "FRAGMENT_DEFINITION")]
|
#[graphql(name = "FRAGMENT_DEFINITION")]
|
||||||
FragmentDefinition,
|
FragmentDefinition,
|
||||||
|
#[graphql(name = "FIELD_DEFINITION")]
|
||||||
|
FieldDefinition,
|
||||||
#[graphql(name = "FRAGMENT_SPREAD")]
|
#[graphql(name = "FRAGMENT_SPREAD")]
|
||||||
FragmentSpread,
|
FragmentSpread,
|
||||||
#[graphql(name = "INLINE_FRAGMENT")]
|
#[graphql(name = "INLINE_FRAGMENT")]
|
||||||
InlineFragment,
|
InlineFragment,
|
||||||
|
#[graphql(name = "ENUM_VALUE")]
|
||||||
|
EnumValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, QueryT, MutationT, SubscriptionT>
|
impl<'a, QueryT, MutationT, SubscriptionT>
|
||||||
|
@ -214,6 +218,10 @@ impl<'a, S> SchemaType<'a, S> {
|
||||||
"include".to_owned(),
|
"include".to_owned(),
|
||||||
DirectiveType::new_include(&mut registry),
|
DirectiveType::new_include(&mut registry),
|
||||||
);
|
);
|
||||||
|
directives.insert(
|
||||||
|
"deprecated".to_owned(),
|
||||||
|
DirectiveType::new_deprecated(&mut registry),
|
||||||
|
);
|
||||||
directives.insert(
|
directives.insert(
|
||||||
"specifiedBy".to_owned(),
|
"specifiedBy".to_owned(),
|
||||||
DirectiveType::new_specified_by(&mut registry),
|
DirectiveType::new_specified_by(&mut registry),
|
||||||
|
@ -545,6 +553,21 @@ where
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn new_deprecated(registry: &mut Registry<'a, S>) -> DirectiveType<'a, S>
|
||||||
|
where
|
||||||
|
S: ScalarValue,
|
||||||
|
{
|
||||||
|
Self::new(
|
||||||
|
"deprecated",
|
||||||
|
&[
|
||||||
|
DirectiveLocation::FieldDefinition,
|
||||||
|
DirectiveLocation::EnumValue,
|
||||||
|
],
|
||||||
|
&[registry.arg::<String>("reason", &())],
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fn new_specified_by(registry: &mut Registry<'a, S>) -> DirectiveType<'a, S>
|
fn new_specified_by(registry: &mut Registry<'a, S>) -> DirectiveType<'a, S>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
|
@ -570,10 +593,12 @@ impl fmt::Display for DirectiveLocation {
|
||||||
DirectiveLocation::Mutation => "mutation",
|
DirectiveLocation::Mutation => "mutation",
|
||||||
DirectiveLocation::Subscription => "subscription",
|
DirectiveLocation::Subscription => "subscription",
|
||||||
DirectiveLocation::Field => "field",
|
DirectiveLocation::Field => "field",
|
||||||
|
DirectiveLocation::FieldDefinition => "field definition",
|
||||||
DirectiveLocation::FragmentDefinition => "fragment definition",
|
DirectiveLocation::FragmentDefinition => "fragment definition",
|
||||||
DirectiveLocation::FragmentSpread => "fragment spread",
|
DirectiveLocation::FragmentSpread => "fragment spread",
|
||||||
DirectiveLocation::InlineFragment => "inline fragment",
|
DirectiveLocation::InlineFragment => "inline fragment",
|
||||||
DirectiveLocation::Scalar => "scalar",
|
DirectiveLocation::Scalar => "scalar",
|
||||||
|
DirectiveLocation::EnumValue => "enum value",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,6 +208,13 @@ async fn test_introspection_directives() {
|
||||||
"INLINE_FRAGMENT",
|
"INLINE_FRAGMENT",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "deprecated",
|
||||||
|
"locations": [
|
||||||
|
"FIELD_DEFINITION",
|
||||||
|
"ENUM_VALUE",
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "specifiedBy",
|
"name": "specifiedBy",
|
||||||
"locations": [
|
"locations": [
|
||||||
|
|
|
@ -1050,6 +1050,12 @@ pub(crate) fn schema_introspection_result() -> Value {
|
||||||
"isDeprecated": false,
|
"isDeprecated": false,
|
||||||
"deprecationReason": null
|
"deprecationReason": null
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "FIELD_DEFINITION",
|
||||||
|
"description": null,
|
||||||
|
"isDeprecated": false,
|
||||||
|
"deprecationReason": null
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "FRAGMENT_SPREAD",
|
"name": "FRAGMENT_SPREAD",
|
||||||
"description": null,
|
"description": null,
|
||||||
|
@ -1067,6 +1073,12 @@ pub(crate) fn schema_introspection_result() -> Value {
|
||||||
"description": null,
|
"description": null,
|
||||||
"isDeprecated": false,
|
"isDeprecated": false,
|
||||||
"deprecationReason": null
|
"deprecationReason": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ENUM_VALUE",
|
||||||
|
"description": null,
|
||||||
|
"isDeprecated": false,
|
||||||
|
"deprecationReason": null
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"possibleTypes": null
|
"possibleTypes": null
|
||||||
|
@ -1376,6 +1388,31 @@ pub(crate) fn schema_introspection_result() -> Value {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "deprecated",
|
||||||
|
"description": null,
|
||||||
|
"isRepeatable": false,
|
||||||
|
"locations": [
|
||||||
|
"FIELD_DEFINITION",
|
||||||
|
"ENUM_VALUE"
|
||||||
|
],
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"name": "reason",
|
||||||
|
"description": null,
|
||||||
|
"type": {
|
||||||
|
"kind": "NON_NULL",
|
||||||
|
"name": null,
|
||||||
|
"ofType": {
|
||||||
|
"kind": "SCALAR",
|
||||||
|
"name": "String",
|
||||||
|
"ofType": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultValue": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "specifiedBy",
|
"name": "specifiedBy",
|
||||||
"description": null,
|
"description": null,
|
||||||
|
@ -2345,6 +2382,11 @@ pub(crate) fn schema_introspection_result_without_descriptions() -> Value {
|
||||||
"isDeprecated": false,
|
"isDeprecated": false,
|
||||||
"deprecationReason": null
|
"deprecationReason": null
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "FIELD_DEFINITION",
|
||||||
|
"isDeprecated": false,
|
||||||
|
"deprecationReason": null
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "FRAGMENT_SPREAD",
|
"name": "FRAGMENT_SPREAD",
|
||||||
"isDeprecated": false,
|
"isDeprecated": false,
|
||||||
|
@ -2359,6 +2401,11 @@ pub(crate) fn schema_introspection_result_without_descriptions() -> Value {
|
||||||
"name": "SCALAR",
|
"name": "SCALAR",
|
||||||
"isDeprecated": false,
|
"isDeprecated": false,
|
||||||
"deprecationReason": null
|
"deprecationReason": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ENUM_VALUE",
|
||||||
|
"isDeprecated": false,
|
||||||
|
"deprecationReason": null
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"possibleTypes": null
|
"possibleTypes": null
|
||||||
|
@ -2650,6 +2697,29 @@ pub(crate) fn schema_introspection_result_without_descriptions() -> Value {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "deprecated",
|
||||||
|
"isRepeatable": false,
|
||||||
|
"locations": [
|
||||||
|
"FIELD_DEFINITION",
|
||||||
|
"ENUM_VALUE"
|
||||||
|
],
|
||||||
|
"args": [
|
||||||
|
{
|
||||||
|
"name": "reason",
|
||||||
|
"type": {
|
||||||
|
"kind": "NON_NULL",
|
||||||
|
"name": null,
|
||||||
|
"ofType": {
|
||||||
|
"kind": "SCALAR",
|
||||||
|
"name": "String",
|
||||||
|
"ofType": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultValue": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "specifiedBy",
|
"name": "specifiedBy",
|
||||||
"isRepeatable": false,
|
"isRepeatable": false,
|
||||||
|
|
Loading…
Reference in a new issue