You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All previously existing annotations are now PHP native `Attribute`. This
is a major breaking change and all annotations must be migrated to the
new attributes.
Notable changes:
- `API\Argument` is now declared on the parameter itself
- `API\Filter` is used directly, possibly multiple times, without
wrapping in `API\Filters`
- `API\Filters` is not necessary anymore and was dropped
- `API\Sorting` requires a single class name, but can be used multiple
times
# Partially automated migration
The following is a configuration file for [Rector](https://getrector.com)
that will migrate both Doctrine annotations and also GraphQL Doctrine
annotations to attributes.
The migration for GraphQL Doctrine is imperfect, so `Sorting` and
`Argument` will have to be adjusted manually afterward.
```php
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
use Rector\Php80\Rector\Property\NestedAnnotationToAttributeRector;
use Rector\Php80\ValueObject\AnnotationPropertyToAttributeClass;
use Rector\Php80\ValueObject\AnnotationToAttribute;
use Rector\Php80\ValueObject\NestedAnnotationToAttribute;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->parallel();
$rectorConfig->sets([
\Rector\Doctrine\Set\DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
]);
$rectorConfig->ruleWithConfiguration(NestedAnnotationToAttributeRector::class, [
new NestedAnnotationToAttribute('GraphQL\\Doctrine\\Annotation\\Filters', [new AnnotationPropertyToAttributeClass('GraphQL\\Doctrine\\Attribute\\Filter')], \true),
new NestedAnnotationToAttribute('GraphQL\\Doctrine\\Annotation\\Sorting', [new AnnotationPropertyToAttributeClass('GraphQL\\Doctrine\\Attribute\\Sorting', 'classes', \true)]),
new NestedAnnotationToAttribute('API\Filters', [new AnnotationPropertyToAttributeClass('GraphQL\\Doctrine\\Attribute\\Filter')], \true),
new NestedAnnotationToAttribute('API\Sorting', [new AnnotationPropertyToAttributeClass('GraphQL\\Doctrine\\Attribute\\Sorting', 'classes', \true)]),
]);
$rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [
new AnnotationToAttribute('GraphQL\\Doctrine\\Annotation\\Argument', 'GraphQL\\Doctrine\\Attribute\\Argument'),
new AnnotationToAttribute('GraphQL\\Doctrine\\Annotation\\Exclude', 'GraphQL\\Doctrine\\Attribute\\Exclude'),
new AnnotationToAttribute('GraphQL\\Doctrine\\Annotation\\Field', 'GraphQL\\Doctrine\\Attribute\\Field'),
new AnnotationToAttribute('GraphQL\\Doctrine\\Annotation\\FilterGroupCondition', 'GraphQL\\Doctrine\\Attribute\\FilterGroupCondition'),
new AnnotationToAttribute('GraphQL\\Doctrine\\Annotation\\Filter', 'GraphQL\\Doctrine\\Attribute\\Filter'),
new AnnotationToAttribute('GraphQL\\Doctrine\\Annotation\\Input', 'GraphQL\\Doctrine\\Attribute\\Input'),
new AnnotationToAttribute('API\Argument', 'GraphQL\\Doctrine\\Attribute\\Argument'),
new AnnotationToAttribute('API\Exclude', 'GraphQL\\Doctrine\\Attribute\\Exclude'),
new AnnotationToAttribute('API\Field', 'GraphQL\\Doctrine\\Attribute\\Field'),
new AnnotationToAttribute('API\FilterGroupCondition', 'GraphQL\\Doctrine\\Attribute\\FilterGroupCondition'),
new AnnotationToAttribute('API\Filter', 'GraphQL\\Doctrine\\Attribute\\Filter'),
new AnnotationToAttribute('API\Input', 'GraphQL\\Doctrine\\Attribute\\Input'),
]);
};
```
Closes#63
Copy file name to clipboardExpand all lines: README.md
+52-59Lines changed: 52 additions & 59 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,10 +9,10 @@
9
9
[](https://gitter.im/Ecodev/graphql-doctrine)
10
10
11
11
A library to declare GraphQL types from Doctrine entities, PHP type hinting,
12
-
and annotations, and to be used with [webonyx/graphql-php](https://github.com/webonyx/graphql-php).
12
+
and attributes, and to be used with [webonyx/graphql-php](https://github.com/webonyx/graphql-php).
13
13
14
14
It reads most information from type hints, complete some things from existing
15
-
Doctrine annotations and allow further customizations with specialized annotations.
15
+
Doctrine attributes and allow further customizations with specialized attributes.
16
16
It will then create [`ObjectType`](https://webonyx.github.io/graphql-php/type-system/object-types/#object-type-definition) and
0 commit comments