From c89dd1f5e144e63a986fcf09163ccf965a1c83bc Mon Sep 17 00:00:00 2001 From: Maxime Rainville Date: Mon, 26 Nov 2018 15:01:22 +1300 Subject: [PATCH 1/2] MINOR Scaffold some DataObject for testing graphql --- _config/graphql.yml | 59 +++++++++++++++++++++++++++++++++++++++++++++ code/Company.php | 34 +++++++++++++++++++++----- 2 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 _config/graphql.yml diff --git a/_config/graphql.yml b/_config/graphql.yml new file mode 100644 index 0000000..091c04c --- /dev/null +++ b/_config/graphql.yml @@ -0,0 +1,59 @@ +--- +Name: frameworktestgraphql +After: '#graphqlconfig' +--- + +SilverStripe\Core\Injector\Injector: + SilverStripe\GraphQL\Manager.frameworktest: + class: SilverStripe\GraphQL\Manager + constructor: + identifier: frameworktest + SilverStripe\GraphQL\Controller.frameworktest: + class: SilverStripe\GraphQL\Controller + constructor: + manager: '%$SilverStripe\GraphQL\Manager.frameworktest' + + + +SilverStripe\Control\Director: + rules: + 'frameworktest/graphql': + Controller: '%$SilverStripe\GraphQL\Controller.frameworktest' + +SilverStripe\GraphQL\Manager: + schemas: + frameworktest: + typeNames: + SilverStripe\FrameworkTest\Model\Company: Company + SilverStripe\FrameworkTest\Model\Employee: Employee + scaffolding: + types: + SilverStripe\FrameworkTest\Model\Company: + fields: + - ID + - Name + - Category + - Revenue + - CEO + operations: + read: true + update: true + create: true + delete: true + readOne: true + nestedQueries: + Employees: true + PastEmployees: true + SilverStripe\FrameworkTest\Model\Employee: + fields: + - ID + - Name + - Biography + - DateOfBirth + - Category + operations: + read: true + update: true + create: true + delete: true + readOne: true \ No newline at end of file diff --git a/code/Company.php b/code/Company.php index c660466..9776e99 100644 --- a/code/Company.php +++ b/code/Company.php @@ -2,19 +2,41 @@ namespace SilverStripe\FrameworkTest\Model; +use SilverStripe\Assets\Image; use SilverStripe\Forms\DropdownField; +use SilverStripe\ORM\HasManyList; +use SilverStripe\ORM\ManyManyList; use SilverStripe\ORM\ValidationResult; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DB; use SilverStripe\AssetAdmin\Forms\UploadField; use SilverStripe\Versioned\Versioned; +use RelationFieldsTestPage; +use GridFieldTestPage; +/** + * + * @property string $Name + * @property string $Category + * @property float $Revenue + * @property string $CEO + * @property int $RelationFieldsTestPageID + * @property int $GridFieldTestPageID + * @method RelationFieldsTestPage RelationFieldsTestPage() + * @method GridFieldTestPage GridFieldTestPageHasOne() + * @method HasManyList|Employee[] Employees() + * @method HasManyList|Image[] GroupPhotos() + * @method ManyManyList|Employee[] PastEmployees() + * + * @mixin Versioned + * @mixin RecursivePublishable + */ class Company extends DataObject { private static $table_name = 'Company'; private static $extensions = [ - Versioned::class +// Versioned::class ]; /** @@ -29,17 +51,17 @@ class Company extends DataObject ); private static $has_one = array( - 'RelationFieldsTestPage' => 'RelationFieldsTestPage', - 'GridFieldTestPageHasOne' => 'GridFieldTestPage' + 'RelationFieldsTestPage' => RelationFieldsTestPage::class, + 'GridFieldTestPageHasOne' => GridFieldTestPage::class ); private static $has_many = array( - 'Employees' => 'SilverStripe\\FrameworkTest\\Model\\Employee', - 'GroupPhotos' => 'SilverStripe\\Assets\\Image' + 'Employees' => Employee::class, + 'GroupPhotos' => Image::class ); private static $many_many = array( - 'PastEmployees' => 'SilverStripe\\FrameworkTest\\Model\\Employee' + 'PastEmployees' => Employee::class ); private static $many_many_extraFields = array( From 8bd432bef3297587a7c0a0e987679e9ffdfd2354 Mon Sep 17 00:00:00 2001 From: Maxime Rainville Date: Wed, 5 Dec 2018 12:12:29 +1300 Subject: [PATCH 2/2] Undo debug statement. --- code/Company.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Company.php b/code/Company.php index 9776e99..4a1e662 100644 --- a/code/Company.php +++ b/code/Company.php @@ -36,7 +36,7 @@ class Company extends DataObject private static $table_name = 'Company'; private static $extensions = [ -// Versioned::class + Versioned::class ]; /**