How to Improve Query and mutations Performance.
Opened this issue · 5 comments
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
Internally we use suiteCRM beans for retrieving content, which in some occasions is not performant not efficient but is the only way to support hooks/workflow.
If some of the queries are expensive its better to write the query inside the resolver.
for mutations its hard to imagine why will be so slow. include some examples, better yet do some repo with a minimum reproducible code
Thanks for a quick response. I have checked the query takes a long time in the graphql library. I have check query in a terminal and its execute very fast. I think there is some issue in the library which slows response. I have implemented the optimistic approach on the front end so crud operation doesn't affect performance. but listing items take more time.
I have test with echo message in the query instead of sending a request to MySQL server but a static message also takes time so I am sure there is some issue in this library.
Would you please suggest a possible solution to fix the listing performance issue?
Thanks
If you can create a complete example so I can reproduce I will take a look!
Hello
I have checked the first request goes in the rest.php file. I have debuge code " $schema = new SuiteCRMSchema();" take long time. I have commented out all query list parameters in suitecrmschema.php and its working very fast. It seems like when the schema object is called its scan all queries and its parameter and then it returns match query so it takes a long time.
$config->getQuery()->addFields([()]
$app->post('/graphql', function (Request $request, Response $response) {
global $app_strings, $sugar_config, $app_list_strings,$sugar_config;
$default_language = $sugar_config['default_language'];
$app_list_strings = return_app_list_strings_language($default_language);
require_once DIR.'/graphql/Schema/SuiteCRMSchema.php';
require_once DIR.'/graphql/schema-bootstrap.php';
$schema = new SuiteCRMSchema();
$processor = new Processor($schema);
$parsedBody = $request->getParsedBody();
$parsedVariables = $parsedBody['variables'];
$parsedBody = $parsedBody['query'];
$processor->processPayload($parsedBody,$parsedVariables);
return $response->withJson($processor->getResponseData());
});
I have debugged code but didn't find getQuery() and getMutation() method . I have check we can improve 5 times faster performance we can make seperate query list instead of adding all queries in all ''add fields array."
'users' => [
'type' => new UsersListType(),
'args' => argsHelper::entityArgsHelper('Users'),
'resolve' => function ($value, array $args, ResolveInfo $info) {
return $info->getReturnType()->resolve($value, $args, $info);
}
],
Would you please let me know how to resolve this issue.
Thanks
Those methods you refer to is from the underlying graphql library (youshido) and thats the way it works.
I am planning to use a local cache and move over to another graphql -php library in the future but for the moment this is what we have.
If you want to solve it you can statically define each 'args' => argsHelper::entityArgsHelper('Users'),
instead of using the argsHelper. That might be a lot faster, I use to have that in old versions but it was very inconvenient once you started adding fields in the studio you would have to add the new field definition to the schema.