markhuot / craftql

A drop-in GraphQL server for Craft CMS
Other
319 stars 53 forks source link

GraphQLService execute on production #342

Open jimhaakman opened 3 years ago

jimhaakman commented 3 years ago

I've encountered a problem when deploying CraftQL to production. And devmode is not active.

In markhuot\CraftQL\Services\GraphQLService.php

$debug = Craft::$app->config->getGeneral()->devMode ? DebugFlag::INCLUDE_DEBUG_MESSAGE | DebugFlag::RETHROW_INTERNAL_EXCEPTIONS : null;
        return GraphQL::executeQuery($schema, $input, null, null, $variables)->toArray($debug);

This throws an error as GraphQL::executeQuery->toArray expects $debug to be an integer.

Thank you very much.

AlexJezior commented 3 years ago

I am also experiencing this issue as well. The only way to have my application working is to set the ENVIRONMENT=dev, otherwise it's rendered useless. Here's the stacktrace from my web.log:

2021-02-28 23:34:42 [-][1][-][error][TypeError] TypeError: Argument 1 passed to GraphQL\Executor\ExecutionResult::toArray() must be of the type int, null given, called in /var/www/craftsite.com/vendor/markhuot/craftql/src/Services/GraphQLService.php on line 132 and defined in /var/www/craftsite.com/vendor/webonyx/graphql-php/src/Executor/ExecutionResult.php:136
Stack trace:
#0 /var/www/craftsite.com/vendor/markhuot/craftql/src/Services/GraphQLService.php(132): GraphQL\Executor\ExecutionResult->toArray(NULL)
#1 /var/www/craftsite.com/vendor/markhuot/craftql/src/Controllers/ApiController.php(121): markhuot\CraftQL\Services\GraphQLService->execute(Object(GraphQL\Type\Schema), '{\n        globa...', NULL)
#2 [internal function]: markhuot\CraftQL\Controllers\ApiController->actionIndex()
#3 /var/www/craftsite.com/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#4 /var/www/craftsite.com/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#5 /var/www/craftsite.com/vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction('index', Array)
#6 /var/www/craftsite.com/vendor/yiisoft/yii2/base/Module.php(534): craft\web\Controller->runAction('index', Array)
#7 /var/www/craftsite.com/vendor/craftcms/cms/src/web/Application.php(274): yii\base\Module->runAction('craftql/api/ind...', Array)
#8 /var/www/craftsite.com/vendor/yiisoft/yii2/web/Application.php(104): craft\web\Application->runAction('craftql/api/ind...', Array)
#9 /var/www/craftsite.com/vendor/craftcms/cms/src/web/Application.php(259): yii\web\Application->handleRequest(Object(craft\web\Request))
#10 /var/www/craftsite.com/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#11 /var/www/craftsite.com/web/index.php(22): yii\base\Application->run()
#12 {main}
jimhaakman commented 3 years ago

@markhuot can the fix by @redboer get merged?.