@@ -149,13 +149,14 @@ private function getQueryFields(string $resourceClass, ResourceMetadata $resourc
149
149
{
150
150
$ queryFields = [];
151
151
$ shortName = $ resourceMetadata ->getShortName ();
152
+ $ deprecationReason = $ resourceMetadata ->getGraphqlAttribute ('query ' , 'deprecation_reason ' , '' , true );
152
153
153
- if ($ fieldConfiguration = $ this ->getResourceFieldConfiguration ($ resourceClass , $ resourceMetadata , null , new Type (Type::BUILTIN_TYPE_OBJECT , true , $ resourceClass ), $ resourceClass )) {
154
+ if ($ fieldConfiguration = $ this ->getResourceFieldConfiguration ($ resourceClass , $ resourceMetadata , null , $ deprecationReason , new Type (Type::BUILTIN_TYPE_OBJECT , true , $ resourceClass ), $ resourceClass )) {
154
155
$ fieldConfiguration ['args ' ] += ['id ' => ['type ' => GraphQLType::id ()]];
155
156
$ queryFields [lcfirst ($ shortName )] = $ fieldConfiguration ;
156
157
}
157
158
158
- if ($ fieldConfiguration = $ this ->getResourceFieldConfiguration ($ resourceClass , $ resourceMetadata , null , new Type (Type::BUILTIN_TYPE_OBJECT , false , null , true , null , new Type (Type::BUILTIN_TYPE_OBJECT , false , $ resourceClass )), $ resourceClass )) {
159
+ if ($ fieldConfiguration = $ this ->getResourceFieldConfiguration ($ resourceClass , $ resourceMetadata , null , $ deprecationReason , new Type (Type::BUILTIN_TYPE_OBJECT , false , null , true , null , new Type (Type::BUILTIN_TYPE_OBJECT , false , $ resourceClass )), $ resourceClass )) {
159
160
$ queryFields [lcfirst (Inflector::pluralize ($ shortName ))] = $ fieldConfiguration ;
160
161
}
161
162
@@ -169,9 +170,10 @@ private function getMutationFields(string $resourceClass, ResourceMetadata $reso
169
170
{
170
171
$ shortName = $ resourceMetadata ->getShortName ();
171
172
$ resourceType = new Type (Type::BUILTIN_TYPE_OBJECT , true , $ resourceClass );
173
+ $ deprecationReason = $ resourceMetadata ->getGraphqlAttribute ($ mutationName , 'deprecation_reason ' , '' , true );
172
174
173
- if ($ fieldConfiguration = $ this ->getResourceFieldConfiguration ($ resourceClass , $ resourceMetadata , ucfirst ("{$ mutationName }s a $ shortName. " ), $ resourceType , $ resourceClass , false , $ mutationName )) {
174
- $ fieldConfiguration ['args ' ] += ['input ' => $ this ->getResourceFieldConfiguration ($ resourceClass , $ resourceMetadata , null , $ resourceType , $ resourceClass , true , $ mutationName )];
175
+ if ($ fieldConfiguration = $ this ->getResourceFieldConfiguration ($ resourceClass , $ resourceMetadata , ucfirst ("{$ mutationName }s a $ shortName. " ), $ deprecationReason , $ resourceType , $ resourceClass , false , $ mutationName )) {
176
+ $ fieldConfiguration ['args ' ] += ['input ' => $ this ->getResourceFieldConfiguration ($ resourceClass , $ resourceMetadata , null , $ deprecationReason , $ resourceType , $ resourceClass , true , $ mutationName )];
175
177
176
178
if (!$ this ->isCollection ($ resourceType )) {
177
179
$ itemMutationResolverFactory = $ this ->itemMutationResolverFactory ;
@@ -189,7 +191,7 @@ private function getMutationFields(string $resourceClass, ResourceMetadata $reso
189
191
*
190
192
* @return array|null
191
193
*/
192
- private function getResourceFieldConfiguration (string $ resourceClass , ResourceMetadata $ resourceMetadata , string $ fieldDescription = null , Type $ type , string $ rootResource , bool $ input = false , string $ mutationName = null , int $ depth = 0 )
194
+ private function getResourceFieldConfiguration (string $ resourceClass , ResourceMetadata $ resourceMetadata , string $ fieldDescription = null , string $ deprecationReason = '' , Type $ type , string $ rootResource , bool $ input = false , string $ mutationName = null , int $ depth = 0 )
193
195
{
194
196
try {
195
197
if (null === $ graphqlType = $ this ->convertType ($ type , $ input , $ mutationName , $ depth )) {
@@ -258,6 +260,7 @@ private function getResourceFieldConfiguration(string $resourceClass, ResourceMe
258
260
'description ' => $ fieldDescription ,
259
261
'args ' => $ args ,
260
262
'resolve ' => $ resolve ,
263
+ 'deprecationReason ' => $ deprecationReason ,
261
264
];
262
265
} catch (InvalidTypeException $ e ) {
263
266
// just ignore invalid types
@@ -441,7 +444,7 @@ private function getResourceObjectTypeFields(string $resourceClass, ResourceMeta
441
444
continue ;
442
445
}
443
446
444
- if ($ fieldConfiguration = $ this ->getResourceFieldConfiguration ($ resourceClass , $ resourceMetadata , $ propertyMetadata ->getDescription (), $ propertyType , $ resourceClass , $ input , $ mutationName , ++$ depth )) {
447
+ if ($ fieldConfiguration = $ this ->getResourceFieldConfiguration ($ resourceClass , $ resourceMetadata , $ propertyMetadata ->getDescription (), $ propertyMetadata -> getAttribute ( ' deprecation_reason ' , '' ), $ propertyType , $ resourceClass , $ input , $ mutationName , ++$ depth )) {
445
448
$ fields ['id ' === $ property ? '_id ' : $ property ] = $ fieldConfiguration ;
446
449
}
447
450
}
0 commit comments