Merge pull request #56 from open-sausages/pulls/0/graphql-scaffolding

MINOR Scaffold some DataObject for testing graphql
This commit is contained in:
Guy Marriott 2018-12-17 16:22:42 +13:00 committed by GitHub
commit 6dd60fdd3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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; namespace SilverStripe\FrameworkTest\Model;
use SilverStripe\Assets\Image;
use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\DropdownField;
use SilverStripe\ORM\HasManyList;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\ORM\ValidationResult; use SilverStripe\ORM\ValidationResult;
use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DB; use SilverStripe\ORM\DB;
use SilverStripe\AssetAdmin\Forms\UploadField; use SilverStripe\AssetAdmin\Forms\UploadField;
use SilverStripe\Versioned\Versioned; 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 class Company extends DataObject
{ {
private static $table_name = 'Company'; private static $table_name = 'Company';
private static $extensions = [ private static $extensions = [
Versioned::class Versioned::class
]; ];
/** /**
@ -29,17 +51,17 @@ class Company extends DataObject
); );
private static $has_one = array( private static $has_one = array(
'RelationFieldsTestPage' => 'RelationFieldsTestPage', 'RelationFieldsTestPage' => RelationFieldsTestPage::class,
'GridFieldTestPageHasOne' => 'GridFieldTestPage' 'GridFieldTestPageHasOne' => GridFieldTestPage::class
); );
private static $has_many = array( private static $has_many = array(
'Employees' => 'SilverStripe\\FrameworkTest\\Model\\Employee', 'Employees' => Employee::class,
'GroupPhotos' => 'SilverStripe\\Assets\\Image' 'GroupPhotos' => Image::class
); );
private static $many_many = array( private static $many_many = array(
'PastEmployees' => 'SilverStripe\\FrameworkTest\\Model\\Employee' 'PastEmployees' => Employee::class
); );
private static $many_many_extraFields = array( private static $many_many_extraFields = array(