lionixevolve / graphqlsuitecrm Goto Github PK
View Code? Open in Web Editor NEWGraphQL SuiteCRM - Integrate with SuiteCRM using GraphQL
GraphQL SuiteCRM - Integrate with SuiteCRM using GraphQL
How to get a total count of records with query result because I have to implement pagination with the use of total count of records.
Thanks
Hello,
How too uses this library and check queries and mutation using graphql tools. I had just put library in vendor folder. Would you please let me know steps how to test queries and mutation.
Thanks
Hello,
I passed auth token from react application to suite CRM and I have to check whether this token is expired or not in the rest.php file and on that basis I have to return custom message. So how can I return a custom error message and handle in my application.
Thanks.
Hello,
Would you please provide details documentation on how to create custom module schema (queries and mutations ) I have try to explore code but its confusing and didn't get idea how to define schema for custom modules.
Thanks
Hello,
I have to check JWT authentication on each request. So how can I check JWT authentication and where to put my code for verification.
Thanks.
Using GraphiQL, i can query sugarcrm modules and i get just 20 first records. how can i get all records?
Thank you
Hello,
I have checked an additional field not working with the mutation . field working only if it's available on the module. How to pass the relational module field in mutation?
We have checked crmhelper.php files and change code but it's not working.
Thanks
Hello,
I have to pass value from rest.php to SuiteCRMSchema.php when declaring an object of that class. I tried to pass value from rest.php but It gives me an error. So how can I pass value from rest.php file to SuiteCRMSchema.php?
Please give me a solution.
Thanks.
Hello,
I am trying to submit form to create records in suitecrm but mutations not working. Mutations working find with graphql tools but its not working with apollo-react.
Getting Below errors.
{"errors":[{"message":"Must provide an operation."}]}
Environment:
Suitecrm 7.11.2
PHP 7.0.22
NodeJs: 11.9.0
NextJs
React Apollo
Would you please suggest how to fix above issue.
Upon integrating GraphqlSuiteCRM in our project ,we added new schemas and generated new mapping using doctrine .The issue happens when we try to regenerate entities using the command :
php vendor/bin/doctrine orm:generate-entities --regenerate-entities --no-backup ./
we get the following error : Cannot load DB manager .
I would appreciate it if you could provide me more infos about this issue .
Thank you
Hello,
I have to check authentication on each request, So where to create middleware to check authentication.
Thanks.
Hello,
I have create custom module queries and and mutations and its working fine. now i need to filter query based on different arguments. As per your documentations LitsType file is used for query.
I have make custom TaskListType.php file for query list of tasks and its working fine.
// namespace SuiteCRM\Schema;
use Youshido\GraphQL\Type\NonNullType;
use Youshido\GraphQL\Type\ListType\AbstractListType;
use Youshido\GraphQL\Type\TypeMap ;
use Youshido\GraphQL\Execution\ResolveInfo;
require_once 'NoteType.php';
if (!defined('sugarEntry')) {
define('sugarEntry', true);
}
class TasksListType extends AbstractListType
{
public function getItemType()
{
return new TaskType();
}
public function build($config)
{
foreach (argsHelper::entityArgsHelper('Tasks', true) as $field => $type) {
$config->addField($field, $type);
}
public function resolve($value = null, $args = [], $info = null)
{
require_once 'ListHelper.php';
$list=ListHelper('Tasks',$value , $args , $info );
$resultArray = [];
if (is_array($list['list']) && !empty($list['list'])) {
if ($list['list'][0]->ACLAccess('list')) {
foreach ($list['list'] as $item) {
$resultArray[] = TaskType::resolve(null, ['id' => $item->id], $info);
}
} else {
//no access
error_log('no access');
}
return empty($resultArray)? null :$resultArray;
} else {
return null;
}
}
}
Now I want to used same method for tasklist query but add different arguments like tasklist based on start date,end date, developer wise tasks etc,
Would you please provide proper documentations or example how to add custom arguments in query.
Thanks
How to get records by descending order from graphql query. I tried to use order parameter with the field but it gave me records by ascending orders.
Thanks
when i try to use the payload below, i get this message error ("message": "Unknown argument "start_range_date_entered" on field "calls"",)
$payload='{"query":"{\n calls ( start_range_date_entered: "2015-04-01", end_range_date_entered: "2015-06-01") {\n \tname\n date_entered\n\t}\n}","variables":""}';
Hello,
We have created so many custom query and mutations and we have write custom files for queries and mutations but its take more time. Would you please suggest how to improve performance for query and mutation.
Are there any settings in your library or tools to measure query/mutation performance?
Thanks
Hello,
I am creating a custom schema to get data from 2 relational tables. But when I am returning relational table field from graphql query at that time it will give me field not found error. Please suggest me a solution for how to return relational table field value using graphql and suite CRM.
use Youshido\GraphQL\Type\ListType\AbstractListType;
if (!defined('sugarEntry')) {
define('sugarEntry', true);
}
class KanbanTodoitems extends AbstractListType
{
public function getItemType()
{
return new Ti_todoitemsType();
}
public function build($config)
{
}
public function endswith($string, $test)
{
$strlen = strlen($string);
$testlen = strlen($test);
if ($testlen > $strlen) {
return false;
}
return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0;
}
public function resolve($value = null, $args = [], $info = null)
{
global $current_user;
$kanbanid = $args['kanban_ref'];
require_once 'vendor/lionixevolve/graphqlsuitecrm/graphql/Schema/ListHelper.php';
global $db;
$Query = "SELECT ti.id, ti.name, ti.contact_id_c, ti.todolist_id, ti.lession_id, ti.due_date, ti.priority, ti.status,pj.id as project_id, pj.agent_id, c.first_name, hlc.todorepeattype_c, ti.role FROM ti_todoitems ti LEFT JOIN contacts c ON c.id = ti.contact_id_c LEFT JOIN proj_project pj ON ti.todolist_id = pj.todo_list LEFT JOIN hlpkg_todolist_cstm hlc ON hlc.id_c = ti.todolist_id WHERE kanban_ref='$kanbanid' and ti.deleted='0' ORDER By convert(ti.task_order,unsigned) ASC";
$result = $db->query($Query);
if($result) {
return $result;
} else {
return null;
}
}
}
Hello,
I am trying to get relation module data but its not working properly. I have define custom relationship with Notes module i have checked NotesType.php file in schema folder and i have extend code for todoitem(custom module relationship with notes) but its not working.
NoteType.php
<?php
use Youshido\GraphQL\Type\Object\AbstractObjectType;
use Youshido\GraphQL\Type\Scalar\StringType;
use Youshido\GraphQL\Execution\ResolveInfo;
use Youshido\GraphQL\Type\ListType\ListType;
require_once 'argsHelper.php';
class NoteType extends AbstractObjectType // extending abstract Object type
{
public function build($config) // implementing an abstract function where you build your type
{
foreach (argsHelper::entityArgsHelper('Notes') as $field => $type) {
$config->addField($field, $type);
}
$config->addField('created_user_details', [
'type' => new UserType(),
'resolve' => function ($value, array $args, ResolveInfo $info) {
if (!empty($value['created_user_details'])) {
$args['id']=$value['created_user_details'];
return UserType::resolve($value, $args, $info);
} else {
return null;
}
},
]);
$config->addField('assigned_user_details',[
'type' => new UserType(),
'resolve' => function ($value, array $args, ResolveInfo $info) {
if (!empty($value['assigned_user_details'])) {
$args['id']=$value['assigned_user_details'];
return UserType::resolve($value, $args, $info);
} else {
return null;
}
},
]);
$config->addField('modified_user_details', [
'type' => new UserType(),
'resolve' => function ($value, array $args, ResolveInfo $info) {
if (!empty($value['modified_user_details'])) {
$args['id']=$value['modified_user_details'];
return UserType::resolve($value, $args, $info);
} else {
return null;
}
},
]);
$config->addField('contact_details', [
'type' => new ContactType(),
'resolve' => function ($value, array $args, ResolveInfo $info) {
if (!empty($value['contact_details'])) {
$args['id']=$value['contact_details'];
return ContactType::resolve($value, $args, $info);
} else {
return null;
}
},
]);
$config->addField('parent_contact', [
'type' => new ContactType(),
'args' => argsHelper::entityArgsHelper('Contacts'),
'resolve' => function ($value, array $args, ResolveInfo $info) {
if (!empty($value['parent_contact'])) {
$args['id']=$value['parent_contact'];
return ContactType::resolve($value, $args, $info);
} else {
return null;
}
},
]);
$config->addField('parent_account', [
'type' => new AccountType(),
'args' => argsHelper::entityArgsHelper('Accounts'),
'resolve' => function ($value, array $args, ResolveInfo $info) {
if (!empty($value['parent_account'])) {
$args['id']=$value['parent_opportunity'];
return AccountType::resolve($value, $args, $info);
} else {
return null;
}
},
]);
$config->addField('parent_opportunity', [
'type' => new OpportunityType(),
'args' => argsHelper::entityArgsHelper('Opportunities'),
'resolve' => function ($value, array $args, ResolveInfo $info) {
if (!empty($value['parent_opportunity'])) {
$args['id']=$value['parent_opportunity'];
return OpportunityType::resolve($value, $args, $info);
} else {
return null;
}
},
]);
$config->addField('contacts',[
'type' => new ContactsListType(),
'args' => argsHelper::entityArgsHelper('Contacts'),
'resolve' => function ($value, array $args, ResolveInfo $info) {
if (!empty($value['contacts'])) {
$args['ids']=$value['contacts'];
return ContactsListType::resolve($value, $args, $info);
} else {
return null;
}
},
]);
$config->addField('accounts', [
'type' => new AccountsListType(),
'args' => argsHelper::entityArgsHelper('Accounts'),
'resolve' => function ($value, array $args, ResolveInfo $info) {
if (!empty($value['accounts'])) {
$args['ids']=$value['accounts'];
return AccountsListType::resolve($value, $args, $info);
} else {
return null;
}
},
]);
$config->addField('opportunities', [
'type'=> new OpportunitiesListType(),
'args' => argsHelper::entityArgsHelper('Opportunities'),
'resolve' => function ($value, array $args, ResolveInfo $info) {
if (!empty($value['opportunities'])) {
$args['ids']=$value['opportunities'];
return OpportunitiesListType::resolve($value, $args,$info);
} else {
return null;
}
},
]);
$config->addField('ti_todoitems_notes', [
'type'=> new Ti_todoitemsListType(),
'args' => argsHelper::entityArgsHelper('ti_todoitems_notes'),
'resolve' => function ($value, array $args, ResolveInfo $info) {
if (!empty($value['ti_todoitems_notes'])) {
$args['ids']=$value['ti_todoitems_notes'];
return Ti_todoitemsListType::resolve($value, $args,$info);
} else {
return null;
}
},
]);
}
private function retrieveNote($id, $info)
{
global $sugar_config, $current_user;
$noteBean = BeanFactory::getBean('Notes');
$note = $noteBean->retrieve($id);
if($info!=null){
$getFieldASTList=$info->getFieldASTList();
$queryFields=[];
foreach ($getFieldASTList as $key => $value) {
$queryFields[$value->getName()]="";
}
}
$module_arr = array();
if ($note->id && $note->ACLAccess('view')) {
$all_fields = $note->column_fields;
foreach ($all_fields as $field) {
if (isset($note->$field) && !is_object($note->$field)) {
$note->$field = from_html($note->$field);
$note->$field = preg_replace("/\r\n/", '<BR>', $note->$field);
$note->$field = preg_replace("/\n/", '<BR>', $note->$field);
$module_arr[$field] = $note->$field;
}
}
$module_arr['created_user_details'] = $module_arr['created_by'];
$module_arr['assigned_user_details'] = $module_arr['assigned_user_id'];
$module_arr['modified_user_details'] = $module_arr['modified_user_id'];
switch ($module_arr['parent_type']) {
case 'Contacts':
$module_arr['parent_contact'] = $module_arr['parent_id'];
$module_arr['parent_account'] = '';
$module_arr['parent_opportunity'] = '';
$module_arr['parent_case'] = '';
$module_arr['parent_email'] = '';
break;
case 'Accounts':
$module_arr['parent_account'] = $module_arr['parent_id'];
$module_arr['parent_contact'] = '';
$module_arr['parent_opportunity'] = '';
$module_arr['parent_case'] = '';
$module_arr['parent_email'] = '';
break;
case 'Opportunities':
$module_arr['parent_opportunity'] = $module_arr['parent_id'];
$module_arr['parent_contact'] = '';
$module_arr['parent_account'] = '';
$module_arr['parent_case'] = '';
$module_arr['parent_email'] = '';
break;
case 'Cases':
$module_arr['parent_opportunity'] = $module_arr['parent_id'];
$module_arr['parent_contact'] = '';
$module_arr['parent_account'] = '';
$module_arr['parent_case'] = $module_arr['parent_id'];
$module_arr['parent_email'] = '';
break;
case 'Emails':
$module_arr['parent_opportunity'] = '';
$module_arr['parent_contact'] = '';
$module_arr['parent_account'] = '';
$module_arr['parent_case'] = '';
$module_arr['parent_email'] = $module_arr['parent_id'];
break;
case 'ti_todoitems_notes':
$module_arr['parent_opportunity'] = '';
$module_arr['parent_contact'] = '';
$module_arr['parent_account'] = '';
$module_arr['parent_case'] = '';
$module_arr['parent_email'] = '';
$module_arr['parent_email'] = '';
break;
default:
$module_arr['parent_opportunity'] = '';
$module_arr['parent_contact'] = '';
$module_arr['parent_account'] = '';
$module_arr['parent_case'] = '';
$module_arr['parent_ti_todoitems_note'] = '';
break;
}
if(isset($queryFields) && array_key_exists('ti_todoitems_notes',$queryFields)){
$module_arr['ti_todoitems_notes'] = array();
foreach ($note->get_linked_beans('ti_todoitems_notes', 'ti_todoitems_notes') as $contact) {
$module_arr['ti_todoitems_notes'][] = $contact->id;
}
}
if(isset($queryFields) && array_key_exists('contacts',$queryFields)){
$module_arr['contacts'] = array();
foreach ($note->get_linked_beans('contacts', 'Contact') as $contact) {
$module_arr['contacts'][] = $contact->id;
}
}
if(isset($queryFields) && array_key_exists('accounts',$queryFields)){
$module_arr['accounts'] = array();
foreach ($note->get_linked_beans('accounts', 'Account') as $account) {
$module_arr['accounts'][] = $account->id;
}
}
if(isset($queryFields) && array_key_exists('opportunities',$queryFields)){
$module_arr['opportunities'] = array();
foreach ($note->get_linked_beans('opportunities', 'Opportunity') as $opportunity) {
$module_arr['opportunities'][] = $opportunity->id;
}
}
$module_arr['contact_details'] = array();
if(isset($queryFields) && array_key_exists('contact_details',$queryFields)){
$module_arr['contact_details'] = $note->contact_id;
}
return $module_arr;
} else {
return null;
}
}
public function resolve($value = null, $args = [], $info = null) // implementing resolve function
{
if (isset($args['id']) && is_array($args['id'])) {
foreach ($args as $key => $noteId) {
// error_log(__LINE__.print_r($args,1));
if (isset($noteId) && is_array($noteId)) {
foreach ($noteId as $key => $noteIdItem) {
$resultArray[] = self::retrieveNote($noteIdItem, $info);
}
} elseif (!empty($noteId)) {
$resultArray[] = self::retrieveNote($noteId, $info);
}
}
return $resultArray;
} elseif (!empty($args['id'])) {
return self::retrieveNote($args['id'],$info);
}
}
public function getName()
{
return 'Note'; // important to use the real name here, it will be used later in the Schema
}
}
Would you please suggest to get pass paramater of custom realtion module query and also provide Mutation example .
Thanks
Using GraphiQL, i can query sugarcrm modules and i get results but in the documentation explorer no schema is available .
I was just wondering to what this issue could be related ? .
Thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.