Skip to content

Commit

Permalink
NEW: Compliance with new SchemaConfig API (#1164)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Carlino committed Dec 1, 2020
1 parent d24a281 commit 91df999
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 35 deletions.
9 changes: 0 additions & 9 deletions _config/graphql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions _graphql/config.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 2 additions & 5 deletions code/GraphQL/Resolvers/AssetAdminResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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'] : [];

Expand Down
9 changes: 1 addition & 8 deletions code/GraphQL/Resolvers/FileTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 1 addition & 7 deletions code/GraphQL/Resolvers/FolderTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,15 @@
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;
use SilverStripe\Versioned\Versioned;
use InvalidArgumentException;
use Exception;

if (!class_exists(DefaultResolverProvider::class)) {
return;
}

class FolderTypeResolver extends DefaultResolverProvider
class FolderTypeResolver
{
/**
* @param Folder $object
Expand Down
7 changes: 1 addition & 6 deletions code/GraphQL/Resolvers/PublicationResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 91df999

Please sign in to comment.