Skip to content

Commit

Permalink
feat: support custom process override
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbarletta committed Nov 28, 2019
1 parent ee928f2 commit 4b5c82d
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 54 deletions.
17 changes: 6 additions & 11 deletions graphql/Schema/AccountType.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,6 @@ public function build($config) // implementing an abstract function where you bu
}
},
]);
if (file_exists(__DIR__ . '/../../../../../graphql/Schema/customAccountType.php')) {
require_once __DIR__ . '/../../../../../graphql/Schema/customAccountType.php';
if (method_exists(customAccountType, getFields)) {
$customFields = customAccountType::getFields();
foreach ($customFields as $field => $type) {
$config->addField($field, $type);
}

}
}
}

public function resolve($value = null, $args = [], ResolveInfo $info = null)
Expand Down Expand Up @@ -310,7 +300,12 @@ public function retrieve($id, $info = null) // implementing resolve function
if (isset($queryFields) && array_key_exists('created_user_details', $queryFields)) {
$module_arr['created_user_details'] = $module_arr['created_by'];
}

if (file_exists(__DIR__ . '/../../../../../graphql/Schema/customAccountType.php')) {
require_once __DIR__ . '/../../../../../graphql/Schema/customAccountType.php';
if (method_exists('customAccountType', 'processFields')) {
$module_arr = customAccountType::processFields($contact, $queryFields, $module_arr);
}
}
return $module_arr;
} else {
return null;
Expand Down
6 changes: 6 additions & 0 deletions graphql/Schema/CallType.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ private function retrieveCall($id, $info)
$module_arr['notes'][] = $note->id;
}
}
if (file_exists(__DIR__ . '/../../../../../graphql/Schema/customCallType.php')) {
require_once __DIR__ . '/../../../../../graphql/Schema/customCallType.php';
if (method_exists('customCallType', 'processFields')) {
$module_arr = customCallType::processFields($contact, $queryFields, $module_arr);
}
}

return $module_arr;
} else {
Expand Down
14 changes: 6 additions & 8 deletions graphql/Schema/CaseType.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,6 @@ public function build($config) // implementing an abstract function where you b
}
},
]);
if (file_exists(__DIR__ . '/../../../../../graphql/Schema/customCaseType.php')) {
require_once __DIR__ . '/../../../../../graphql/Schema/customCaseType.php';
$customFields = customCaseType::getFields();
foreach ($customFields as $field => $type) {
$config->addField($field, $type);
}
}

}
private function retrieveCase($id, $info)
{
Expand Down Expand Up @@ -210,6 +202,12 @@ private function retrieveCase($id, $info)
if(isset($queryFields) && array_key_exists('account_details',$queryFields)){
$module_arr['account_details'] = $case->account_id;
}
if (file_exists(__DIR__ . '/../../../../../graphql/Schema/customCaseType.php')) {
require_once __DIR__ . '/../../../../../graphql/Schema/customCaseType.php';
if (method_exists('customCaseType', 'processFields')) {
$module_arr = customCaseType::processFields($contact, $queryFields, $module_arr);
}
}
return $module_arr;
} else {
return null;
Expand Down
11 changes: 1 addition & 10 deletions graphql/Schema/ContactType.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,6 @@ public function build($config) // implementing an abstract function where you b
}
},
]);
if (file_exists(__DIR__ . '/../../../../../graphql/Schema/customContactType.php')) {
require_once __DIR__ . '/../../../../../graphql/Schema/customContactType.php';
if (method_exists(customContactType, getFields)) {
$customFields = customContactType::getFields();
foreach ($customFields as $field => $type) {
$config->addField($field, $type);
}
}
}
}
private function retrieveContact($id, $info = null)
{
Expand Down Expand Up @@ -182,7 +173,7 @@ private function retrieveContact($id, $info = null)
}
if (file_exists(__DIR__ . '/../../../../../graphql/Schema/customContactType.php')) {
require_once __DIR__ . '/../../../../../graphql/Schema/customContactType.php';
if (method_exists(customContactType, processFields)) {
if (method_exists('customContactType', 'processFields')) {
$module_arr = customContactType::processFields($contact, $queryFields, $module_arr);
}
}
Expand Down
6 changes: 6 additions & 0 deletions graphql/Schema/MeetingType.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ private function retrieveMeeting($id, $info)
$module_arr['opportunities'][] = $account->id;
}
}
if (file_exists(__DIR__ . '/../../../../../graphql/Schema/customMeetingType.php')) {
require_once __DIR__ . '/../../../../../graphql/Schema/customMeetingType.php';
if (method_exists('customMeetingType', 'processFields')) {
$module_arr = customMeetingType::processFields($contact, $queryFields, $module_arr);
}
}
return $module_arr;
} else {
return null;
Expand Down
6 changes: 6 additions & 0 deletions graphql/Schema/NoteType.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ private function retrieveNote($id, $info)
if(isset($queryFields) && array_key_exists('contact_details',$queryFields)){
$module_arr['contact_details'] = $note->contact_id;
}
if (file_exists(__DIR__ . '/../../../../../graphql/Schema/customNoteType.php')) {
require_once __DIR__ . '/../../../../../graphql/Schema/customNoteType.php';
if (method_exists('customNoteType', 'processFields')) {
$module_arr = customNoteType::processFields($contact, $queryFields, $module_arr);
}
}
return $module_arr;
} else {
return null;
Expand Down
11 changes: 1 addition & 10 deletions graphql/Schema/OpportunityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,6 @@ public function build($config) // implementing an abstract function where you b
}
},
]);
if (file_exists(__DIR__ . '/../../../../../graphql/Schema/customOpportunityType.php')) {
require_once __DIR__ . '/../../../../../graphql/Schema/customOpportunityType.php';
if (method_exists(customAccountType, getFields)) {
$customFields = customOpportunityType::getFields();
foreach ($customFields as $field => $type) {
$config->addField($field, $type);
}
}
}
}

public function resolve($value = null, $args = [], ResolveInfo $info = null)
Expand Down Expand Up @@ -235,7 +226,7 @@ public function retrieve($id, $info = null) // implementing resolve function
}
if (file_exists(__DIR__ . '/../../../../../graphql/Schema/customOpportunityType.php')) {
require_once __DIR__ . '/../../../../../graphql/Schema/customOpportunityType.php';
if (method_exists(customOpportunityType, processFields)) {
if (method_exists(customOpportunityType, 'processFields')) {
$module_arr = customOpportunityType::processFields($contact, $queryFields, $module_arr);
}
}
Expand Down
12 changes: 9 additions & 3 deletions graphql/Schema/TaskType.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ private function retrieveTask($id, $info)
$module_arr['related_opportunities'][] = $opportunity->id;
}
}
if (file_exists(__DIR__ . '/../../../../../graphql/Schema/customTaskType.php')) {
require_once __DIR__ . '/../../../../../graphql/Schema/customTaskType.php';
if (method_exists('customTaskType', 'processFields')) {
$module_arr = customTaskType::processFields($contact, $queryFields, $module_arr);
}
}
return $module_arr;
} else {
return null;
Expand All @@ -171,8 +177,8 @@ public function resolve($value = null, $args = [], $info = null ) // implementi
{
if (isset($args['id']) && is_array($args['id'])) {
foreach ($args as $key => $taskId) {
if (isset($taskId) && is_array($noteId)) {
foreach ($noteId as $key => $taskIdItem) {
if (isset($taskId) && is_array($taskId)) {
foreach ($taskId as $key => $taskIdItem) {
$resultArray[] = self::retrieveTask($taskIdItem, $info );
}
} elseif (!empty($taskId)) {
Expand All @@ -182,7 +188,7 @@ public function resolve($value = null, $args = [], $info = null ) // implementi

return $resultArray;
} elseif (!empty($args['id'])) {
return self::retrieveTask($args['id']);
return self::retrieveTask($args['id'],$info);
}
}

Expand Down
17 changes: 6 additions & 11 deletions graphql/Schema/UserType.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ public function build($config) // implementing an abstract function where you b
}
},
]);
if(file_exists(__DIR__.'/../../../../../graphql/CustomSuiteCRMSchema.php')){
require_once(__DIR__.'/../../../../../graphql/CustomSuiteCRMSchema.php');
if(method_exists('CustomSuiteCRMSchema','buildUserType')){
CustomSuiteCRMSchema::buildUserType($config);
}
}
}
private function retrieveUser($id, $info)
{
Expand Down Expand Up @@ -83,12 +77,13 @@ private function retrieveUser($id, $info)
$module_arr['related_roles'][] = $row['id'];
}
}
if(file_exists(__DIR__.'/../../../../../graphql/CustomSuiteCRMSchema.php')){
require_once(__DIR__.'/../../../../../graphql/CustomSuiteCRMSchema.php');
if(method_exists('CustomSuiteCRMSchema', 'buildUserResolve')){
$module_arr=array_merge($module_arr, CustomSuiteCRMSchema::buildUserResolve($user, $queryFields));
}
if (file_exists(__DIR__ . '/../../../../../graphql/Schema/customUserType.php')) {
require_once __DIR__ . '/../../../../../graphql/Schema/customUserType.php';
if (method_exists(customUserType, 'processFields')) {
$module_arr = customUserType::processFields($contact, $queryFields, $module_arr);
}
}


// $m1 = 'Users';
// $m2 = 'ACLRoles';
Expand Down
2 changes: 1 addition & 1 deletion graphql/Schema/argsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function entityArgsHelper($entity, $mutation = false)
$customOverrideFile='custom' .$entity.'Type.php';
if (file_exists(__DIR__ . '/../../../../../graphql/Schema/'.$customOverrideFile)) {
require_once __DIR__ . '/../../../../../graphql/Schema/'.$customOverrideFile;
if (method_exists($customOverrideFile, getFields)) {
if (method_exists($customOverrideFile, 'getFields')) {
$customFields = $customOverrideFile::getFields();
foreach ($customFields as $field => $type) {
$argsArray = array_merge($argsArray, [
Expand Down

0 comments on commit 4b5c82d

Please sign in to comment.