From 59a90c441191f673d73381e2819e82fd9c1b4761 Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Wed, 11 May 2022 16:38:36 +1200 Subject: [PATCH] BUG: Backwards compatibility patch fix. --- _legacy/SnapshotScaffoldingProvider.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/_legacy/SnapshotScaffoldingProvider.php b/_legacy/SnapshotScaffoldingProvider.php index 96f7ccc..4c14652 100644 --- a/_legacy/SnapshotScaffoldingProvider.php +++ b/_legacy/SnapshotScaffoldingProvider.php @@ -11,7 +11,7 @@ use SilverStripe\ORM\DataObject; use SilverStripe\Security\Member; -if (!interface_exists(ScaffoldingProvider::class) || !class_exists(ReadOneLegacyResolver::class)) { +if (!interface_exists(ScaffoldingProvider::class)) { return; } @@ -49,13 +49,22 @@ public function provideGraphQLScaffolding(SchemaScaffolder $scaffolder): void $fields[] = 'AbsoluteLink'; } - $scaffolder->type($inst->baseClass()) - ->addFields($fields) - ->operation(SchemaScaffolder::READ_ONE) - ->addArg('filter', 'IDFilterType!') - ->setResolver(new ReadOneLegacyResolver($inst)) - ->end() - ->operation('rollback'); + if (class_exists(ReadOneLegacyResolver::class)) { + $scaffolder->type($inst->baseClass()) + ->addFields($fields) + ->operation(SchemaScaffolder::READ_ONE) + ->addArg('filter', 'IDFilterType!') + ->setResolver(new ReadOneLegacyResolver($inst)) + ->end() + ->operation('rollback'); + } else { + $scaffolder->type($inst->baseClass()) + ->addFields($fields) + ->operation(SchemaScaffolder::READ_ONE) + ->addArg('filter', 'IDFilterType!') + ->end() + ->operation('rollback'); + } } } }