diff --git a/_config/graphql.yml b/_config/graphql.yml index 9e20b038f..fb89f0b72 100644 --- a/_config/graphql.yml +++ b/_config/graphql.yml @@ -3,17 +3,8 @@ Name: asset-admin-graphql Only: classexists: 'SilverStripe\GraphQL\Schema\Schema' --- -SilverStripe\Core\Injector\Injector: - SilverStripe\GraphQL\Schema\Registry\ResolverRegistry: - constructor: - assetAdminResolver: '%$SilverStripe\AssetAdmin\GraphQL\Resolvers\AssetAdminResolver' - fileTypeResolver: '%$SilverStripe\AssetAdmin\GraphQL\Resolvers\FileTypeResolver' - folderTypeResolver: '%$SilverStripe\AssetAdmin\GraphQL\Resolvers\FolderTypeResolver' - publicationResolver: '%$SilverStripe\AssetAdmin\GraphQL\Resolvers\PublicationResolver' SilverStripe\GraphQL\Schema\Schema: schemas: admin: src: assetAdmin: 'silverstripe/asset-admin: _graphql' - builders: - assetAdmin: SilverStripe\AssetAdmin\GraphQL\Schema\Builder diff --git a/_graphql/config.yml b/_graphql/config.yml new file mode 100644 index 000000000..c2ccd16d9 --- /dev/null +++ b/_graphql/config.yml @@ -0,0 +1,7 @@ +resolvers: + - SilverStripe\AssetAdmin\GraphQL\Resolvers\AssetAdminResolver + - SilverStripe\AssetAdmin\GraphQL\Resolvers\FileTypeResolver + - SilverStripe\AssetAdmin\GraphQL\Resolvers\FolderTypeResolver + - SilverStripe\AssetAdmin\GraphQL\Resolvers\PublicationResolver +execute: + - SilverStripe\AssetAdmin\GraphQL\Schema\Builder diff --git a/code/GraphQL/Resolvers/AssetAdminResolver.php b/code/GraphQL/Resolvers/AssetAdminResolver.php index ddcb2b401..825f15192 100644 --- a/code/GraphQL/Resolvers/AssetAdminResolver.php +++ b/code/GraphQL/Resolvers/AssetAdminResolver.php @@ -19,10 +19,7 @@ use SilverStripe\Versioned\Versioned; use InvalidArgumentException; -if (!class_exists(DefaultResolverProvider::class)) { - return; -} -class AssetAdminResolver extends DefaultResolverProvider +class AssetAdminResolver { public static function resolveFileInterfaceType($object) { @@ -263,7 +260,7 @@ public static function resolveReadFileUsage($object, array $args, $context, Reso * @return DataList|Filterable * @throws HTTPResponse_Exception */ - public static function resolveReadFiles($object, array $args, $context, $info) + public static function resolveReadFiles($object, array $args = [], $context = [], $info = null) { $filter = (!empty($args['filter'])) ? $args['filter'] : []; diff --git a/code/GraphQL/Resolvers/FileTypeResolver.php b/code/GraphQL/Resolvers/FileTypeResolver.php index 80c6cb0a4..85909f724 100644 --- a/code/GraphQL/Resolvers/FileTypeResolver.php +++ b/code/GraphQL/Resolvers/FileTypeResolver.php @@ -3,22 +3,15 @@ namespace SilverStripe\AssetAdmin\GraphQL\Resolvers; -use GraphQL\Type\Definition\ResolveInfo; use SilverStripe\AssetAdmin\Controller\AssetAdmin; use SilverStripe\AssetAdmin\Forms\UploadField; use SilverStripe\AssetAdmin\Model\ThumbnailGenerator; use SilverStripe\Assets\File; -use SilverStripe\Assets\Folder; use SilverStripe\Assets\Storage\AssetContainer; use SilverStripe\Core\Injector\Injectable; -use SilverStripe\GraphQL\Schema\DataObject\FieldAccessor; -use SilverStripe\GraphQL\Schema\Resolver\DefaultResolverProvider; -if (!class_exists(DefaultResolverProvider::class)) { - return; -} -class FileTypeResolver extends DefaultResolverProvider +class FileTypeResolver { use Injectable; diff --git a/code/GraphQL/Resolvers/FolderTypeResolver.php b/code/GraphQL/Resolvers/FolderTypeResolver.php index 1cfe65a5a..17fffddaa 100644 --- a/code/GraphQL/Resolvers/FolderTypeResolver.php +++ b/code/GraphQL/Resolvers/FolderTypeResolver.php @@ -8,9 +8,7 @@ use SilverStripe\AssetAdmin\GraphQL\FileFilter; use SilverStripe\Assets\File; use SilverStripe\Assets\Folder; -use SilverStripe\GraphQL\Pagination\Connection; use SilverStripe\GraphQL\QueryHandler\QueryHandler; -use SilverStripe\GraphQL\Schema\Resolver\DefaultResolverProvider; use SilverStripe\ORM\DataList; use SilverStripe\ORM\DataQuery; use SilverStripe\ORM\DB; @@ -18,11 +16,7 @@ use InvalidArgumentException; use Exception; -if (!class_exists(DefaultResolverProvider::class)) { - return; -} - -class FolderTypeResolver extends DefaultResolverProvider +class FolderTypeResolver { /** * @param Folder $object diff --git a/code/GraphQL/Resolvers/PublicationResolver.php b/code/GraphQL/Resolvers/PublicationResolver.php index 32b7400d5..6801d012e 100644 --- a/code/GraphQL/Resolvers/PublicationResolver.php +++ b/code/GraphQL/Resolvers/PublicationResolver.php @@ -7,16 +7,11 @@ use SilverStripe\AssetAdmin\GraphQL\Notice; use SilverStripe\Assets\File; use SilverStripe\GraphQL\QueryHandler\QueryHandler; -use SilverStripe\GraphQL\Schema\Resolver\DefaultResolverProvider; use SilverStripe\Versioned\RecursivePublishable; use SilverStripe\Versioned\Versioned; use InvalidArgumentException; -if (!class_exists(DefaultResolverProvider::class)) { - return; -} - -class PublicationResolver extends DefaultResolverProvider +class PublicationResolver { const ACTION_PUBLISH = 'publish'; const ACTION_UNPUBLISH = 'unpublish';