MINOR Scaffold some DataObject for testing graphql

This commit is contained in:
Maxime Rainville 2018-11-26 15:01:22 +13:00
parent cace7979aa
commit c89dd1f5e1
2 changed files with 87 additions and 6 deletions

59
_config/graphql.yml Normal file
View File

@ -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

View File

@ -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(