在 Lighthouse 中,resolver 所对应的类方法 __invoke 未执行的排查分析
1、GraphQL 架构定义如下
"获取主题页面的配置" templateDetails(basename: String!): OnlineStoreThemeTemplateDetails @field(resolver: "Modules\\OnlineStoreThemeGraphQL\\Resolver\\OnlineStoreTheme\\TemplateDetailsResolver") type OnlineStoreThemeTemplateDetails { sectionsData: [OnlineStoreThemeSection] sectionSchemas: [OnlineStoreThemeSectionSchema] }
2、在类 TemplateDetailsResolver 中方法 __invoke 中打印输出 1,未输出。如图1
public function __invoke($rootValue, array $args, GraphQLContext $context, ResolveInfo $resolveInfo) { echo 1; exit; }
"templateDetails": { "sectionsData": null, "sectionSchemas": null },
3、GraphQL 架构定义还原如下,则对应的类方法 __invoke 能够执行到。如图2
"获取主题页面的配置" templateDetails(basename: String!): [OnlineStoreThemeSection] @field(resolver: "Modules\\OnlineStoreThemeGraphQL\\Resolver\\OnlineStoreTheme\\TemplateDetailsResolver") type OnlineStoreThemeTemplateDetails { sectionsData: [OnlineStoreThemeSection] sectionSchemas: [OnlineStoreThemeSectionSchema] }
4、决定拆分 GraphQL 架构定义,则对应的类方法 __invoke 能够执行到。
"获取主题页面的配置" templateDetails(basename: String!): OnlineStoreThemeTemplateDetails type OnlineStoreThemeTemplateDetails { sectionsData: [OnlineStoreThemeSection] @field(resolver: "Modules\\OnlineStoreThemeGraphQL\\Resolver\\OnlineStoreTheme\\TemplateDetailsResolver") sectionSchemas: [OnlineStoreThemeSectionSchema] }
5、GraphQL 架构定义调整解析类,则对应的类方法 __invoke 能够执行到。确认问题根源在于解析类本身。
"获取主题页面的配置" templateDetails(basename: String!): OnlineStoreThemeTemplateDetails @field(resolver: "Modules\\OnlineStoreThemeGraphQL\\Resolver\\SectionPresetsByBaseNameResolver") type OnlineStoreThemeTemplateDetails { sectionsData: [OnlineStoreThemeSection] sectionSchemas: [OnlineStoreThemeSectionSchema] }
6、还原至步骤 1 ,决定沿用此架构,在类的构造方法中调试程序,查看调用栈。也确认了 __construct 可以执行,但是 __invoke 未执行到。比较类(Modules\\OnlineStoreThemeGraphQL\\Resolver\\SectionPresetsByBaseNameResolver) 与 类(Modules\\OnlineStoreThemeGraphQL\\Resolver\\OnlineStoreTheme\\TemplateDetailsResolver)
<?php namespace Modules\OnlineStoreThemeGraphQL\Resolver; use Modules\OnlineStoreThemeGraphQL\Resolver\Id; use Modules\ThemeSetting\Schema\RawSchemaLoaderInterface; use Modules\ThemeSetting\Schema\Builder\SectionBuilder; use Modules\ThemeSetting\Schema\Dto\Section; use Nuwave\Lighthouse\Support\Contracts\GraphQLContext; use GraphQL\Type\Definition\ResolveInfo; use Modules\OnlineStoreThemeGraphQL\Resolver\OnlineStoreTheme\ResolveSectionSchema; use Modules\ThemeSetting\Schema\Dto\Section\Block; use Modules\ThemeSetting\Schema\Dto\Section\Setting\BlockSetting; use Modules\ThemeSetting\Schema\Dto\Section\Setting\SectionDefault; use Modules\ThemeSetting\Schema\Dto\Section\Setting\SectionSetting; use Wwwision\RelayPagination\Loader\ArrayLoader; use Wwwision\RelayPagination\Loader\Loader; class SectionPresetsByBaseNameResolver { use ResolveSectionSchema; private SectionBuilder $sectionBuilder; private RawSchemaLoaderInterface $rawSectionSchemaLoader; public function __construct(RawSchemaLoaderInterface $rawSectionSchemaLoader, SectionBuilder $sectionBuilder) { $this->sectionBuilder = $sectionBuilder; $this->rawSectionSchemaLoader = $rawSectionSchemaLoader; } public function __invoke($rootValue, array $args, GraphQLContext $context, ResolveInfo $resolveInfo):Loader { $basename = $args['basename']; $query = $args['query']??null; $themeId = $rootValue['sectionPresetsByBasename']['theme_id']; $rawSchemas = $this->rawSectionSchemaLoader->loadAllSectionSchemas(); $excludedSections = array_merge([Block::APP_BLOCK_SECTION], config('theme_setting.schema.allowed_sections')); $sectionSettings = collect($rawSchemas)->filter(function($rawSchema, $type) use($excludedSections){ // Skip app wrapper 组件 return !in_array($type, $excludedSections); })->map(function($rawSchema, $type) use($themeId){ $id = Id::createSectionSchemaId($themeId, $type); $section = new Section(); $this->sectionBuilder->build($rawSchema, $section); return [ 'categoryName' => 'None', 'id' => $id, 'name' => $section->getName(), 'section' => $this->resolveSectionSetting($id, $id, $themeId, $this->preparePreset($section, $type), $section) ]; }); $loader = new ArrayLoader($sectionSettings->toArray()); return $loader; } private function preparePreset(Section $section, string $type): SectionSetting { $defaultSectionSetting = $section->hasPresets() ? head(array_values($section->getPresets())): $section->getDefault(); $presetSettings = []; foreach($section->getIdentifiedSettings() as $id => $setting) { $presetSettings[$id] = $setting->getDefault(); } $presetSettings = array_merge($presetSettings, $defaultSectionSetting? $defaultSectionSetting->getSettings(): []); $sectionSetting = new SectionSetting(); $sectionSetting->setSettings($presetSettings ); $sectionSetting->setBlocks($this->prepareBlockSettings($section, $defaultSectionSetting)); $sectionSetting->setType($type); return $sectionSetting; } private function prepareBlockSettings(Section $section, SectionDefault $defaultSectionSetting = null) { $sectionDefaultBlockSettings = []; foreach($section->getBlocks() as $block) { $settings = []; foreach($block->getSettings() as $setting) { $settings[$setting->getId()] = $setting->getDefault(); } $blockSetting = new BlockSetting(); $blockSetting->setType($block->getType()); $blockSetting->setSettings($settings); $sectionDefaultBlockSettings[$block->getType()] = $blockSetting; } // Merge block settings if ($defaultSectionSetting) { $blockSettings = $defaultSectionSetting->getBlocks(); foreach($blockSettings as $blockSetting) { /** * @var \Modules\ThemeSetting\Schema\Dto\Section\Setting\BlockSetting */ $defaultBlockSetting = $sectionDefaultBlockSettings[$blockSetting->getType()]; $blockSetting->setSettings(array_merge($defaultBlockSetting->getSettings(), $blockSetting->getSettings())); } return $blockSettings; } return $sectionDefaultBlockSettings; } }
<?php namespace Modules\OnlineStoreThemeGraphQL\Resolver\OnlineStoreTheme; use Nuwave\Lighthouse\Support\Contracts\GraphQLContext; use GraphQL\Type\Definition\ResolveInfo; use Modules\OnlineStoreThemeGraphQL\GraphQl\Exception\GraphQlInputException; use Modules\OnlineStoreThemeGraphQL\Resolver\Id; use Modules\OnlineStoreThemeGraphQL\ThemeSetting\RawSchemaLoaderAdapter; use Modules\Theme\ThemeContext; use Modules\ThemeSetting\Schema\Dto\Template; use Modules\ThemeSetting\Schema\Builder\TemplateBuilder; class TemplateDetailsResolver { use ResolveSectionSchema; private ThemeContext $themeContext; private TemplateBuilder $templateBuilder; public function __construct(ThemeContext $themeContext, TemplateBuilder $templateBuilder) { $this->themeContext = $themeContext; $this->templateBuilder = $templateBuilder; } public function __invoke($rootValue, array $args, GraphQLContext $context, ResolveInfo $resolveInfo) { $themeId = $rootValue['templateSettingsData']['theme_id']; $basename = $args['basename']; $rawSchemaLoader = $this->themeContext ->getThemeViewFactory() ->createRawSchemaLoader(); $rawSchemaLoaderAdapter = new RawSchemaLoaderAdapter($rawSchemaLoader); $sessionId = $rootValue['session_id']?? null; $rawSchemaLoaderAdapter->setSessionId($sessionId); try { $rawSchema = $rawSchemaLoaderAdapter->loadTemplateSchema($basename); $template = new Template(); $this->templateBuilder->build($rawSchema, $template); } catch(\Exception $e) { throw new GraphQlInputException($e->getMessage()); } $id = new Id([$themeId, $basename]); return []; foreach($template as $sectionId => $section) { list($schema, $setting) = $section; $globalSectionId = $id->with($sectionId); yield $this->resolveSectionSetting($globalSectionId, $sectionId, $themeId, $setting, $schema); } } }
{ "message": "Call to undefined function Modules\\OnlineStoreThemeGraphQL\\Resolver\\OnlineStoreTheme\\checkhere()", "exception": "Symfony\\Component\\Debug\\Exception\\FatalThrowableError", "file": "E:\\wwwroot\\object\\Modules\\OnlineStoreThemeGraphQL\\Resolver\\OnlineStoreTheme\\TemplateDetailsResolver.php", "line": 24, "trace": [ { "function": "__construct", "class": "Modules\\OnlineStoreThemeGraphQL\\Resolver\\OnlineStoreTheme\\TemplateDetailsResolver", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php", "line": 843, "function": "newInstanceArgs", "class": "ReflectionClass", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php", "line": 681, "function": "build", "class": "Illuminate\\Container\\Container", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php", "line": 785, "function": "resolve", "class": "Illuminate\\Container\\Container", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php", "line": 629, "function": "resolve", "class": "Illuminate\\Foundation\\Application", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php", "line": 770, "function": "make", "class": "Illuminate\\Container\\Container", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\helpers.php", "line": 120, "function": "make", "class": "Illuminate\\Foundation\\Application", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Support\\Utils.php", "line": 58, "function": "app" }, { "file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Schema\\Directives\\FieldDirective.php", "line": 45, "function": "constructResolver", "class": "Nuwave\\Lighthouse\\Support\\Utils", "type": "::" }, { "file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Schema\\Factories\\FieldFactory.php", "line": 69, "function": "resolveField", "class": "Nuwave\\Lighthouse\\Schema\\Directives\\FieldDirective", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Schema\\TypeRegistry.php", "line": 414, "function": "handle", "class": "Nuwave\\Lighthouse\\Schema\\Factories\\FieldFactory", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Type\\Definition\\UnresolvedFieldDefinition.php", "line": 39, "function": "Nuwave\\Lighthouse\\Schema\\{closure}", "class": "Nuwave\\Lighthouse\\Schema\\TypeRegistry", "type": "::" }, { "file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Type\\Definition\\TypeWithFields.php", "line": 45, "function": "resolve", "class": "GraphQL\\Type\\Definition\\UnresolvedFieldDefinition", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Type\\Definition\\TypeWithFields.php", "line": 33, "function": "findField", "class": "GraphQL\\Type\\Definition\\TypeWithFields", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Validator\\Rules\\OverlappingFieldsCanBeMerged.php", "line": 256, "function": "getField", "class": "GraphQL\\Type\\Definition\\TypeWithFields", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Validator\\Rules\\OverlappingFieldsCanBeMerged.php", "line": 165, "function": "internalCollectFieldsAndFragmentNames", "class": "GraphQL\\Validator\\Rules\\OverlappingFieldsCanBeMerged", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Validator\\Rules\\OverlappingFieldsCanBeMerged.php", "line": 96, "function": "getFieldsAndFragmentNames", "class": "GraphQL\\Validator\\Rules\\OverlappingFieldsCanBeMerged", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Validator\\Rules\\OverlappingFieldsCanBeMerged.php", "line": 64, "function": "findConflictsWithinSelectionSet", "class": "GraphQL\\Validator\\Rules\\OverlappingFieldsCanBeMerged", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Language\\Visitor.php", "line": 414, "function": "GraphQL\\Validator\\Rules\\{closure}", "class": "GraphQL\\Validator\\Rules\\OverlappingFieldsCanBeMerged", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Language\\Visitor.php", "line": 470, "function": "GraphQL\\Language\\{closure}", "class": "GraphQL\\Language\\Visitor", "type": "::" }, { "file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Language\\Visitor.php", "line": 277, "function": "GraphQL\\Language\\{closure}", "class": "GraphQL\\Language\\Visitor", "type": "::" }, { "file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Validator\\DocumentValidator.php", "line": 224, "function": "visit", "class": "GraphQL\\Language\\Visitor", "type": "::" }, { "file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\Validator\\DocumentValidator.php", "line": 116, "function": "visitUsingRules", "class": "GraphQL\\Validator\\DocumentValidator", "type": "::" }, { "file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\GraphQL.php", "line": 153, "function": "validate", "class": "GraphQL\\Validator\\DocumentValidator", "type": "::" }, { "file": "E:\\wwwroot\\object\\vendor\\webonyx\\graphql-php\\src\\GraphQL.php", "line": 94, "function": "promiseToExecute", "class": "GraphQL\\GraphQL", "type": "::" }, { "file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\GraphQL.php", "line": 268, "function": "executeQuery", "class": "GraphQL\\GraphQL", "type": "::" }, { "file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\GraphQL.php", "line": 203, "function": "executeParsedQuery", "class": "Nuwave\\Lighthouse\\GraphQL", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\GraphQL.php", "line": 162, "function": "parseAndExecuteQuery", "class": "Nuwave\\Lighthouse\\GraphQL", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\GraphQL.php", "line": 121, "function": "executeOperation", "class": "Nuwave\\Lighthouse\\GraphQL", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Support\\Utils.php", "line": 99, "function": "Nuwave\\Lighthouse\\{closure}", "class": "Nuwave\\Lighthouse\\GraphQL", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\GraphQL.php", "line": 120, "function": "mapEach", "class": "Nuwave\\Lighthouse\\Support\\Utils", "type": "::" }, { "file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Support\\Http\\Controllers\\GraphQLController.php", "line": 32, "function": "executeOperationOrOperations", "class": "Nuwave\\Lighthouse\\GraphQL", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php", "line": 48, "function": "__invoke", "class": "Nuwave\\Lighthouse\\Support\\Http\\Controllers\\GraphQLController", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php", "line": 219, "function": "dispatch", "class": "Illuminate\\Routing\\ControllerDispatcher", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php", "line": 176, "function": "runController", "class": "Illuminate\\Routing\\Route", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php", "line": 681, "function": "run", "class": "Illuminate\\Routing\\Route", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 130, "function": "Illuminate\\Routing\\{closure}", "class": "Illuminate\\Routing\\Router", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Support\\Http\\Middleware\\AttemptAuthentication.php", "line": 34, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 171, "function": "handle", "class": "Nuwave\\Lighthouse\\Support\\Http\\Middleware\\AttemptAuthentication", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Support\\Http\\Middleware\\AcceptJson.php", "line": 27, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 171, "function": "handle", "class": "Nuwave\\Lighthouse\\Support\\Http\\Middleware\\AcceptJson", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 105, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php", "line": 683, "function": "then", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php", "line": 658, "function": "runRouteWithinStack", "class": "Illuminate\\Routing\\Router", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php", "line": 624, "function": "runRoute", "class": "Illuminate\\Routing\\Router", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php", "line": 613, "function": "dispatchToRoute", "class": "Illuminate\\Routing\\Router", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php", "line": 170, "function": "dispatch", "class": "Illuminate\\Routing\\Router", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 130, "function": "Illuminate\\Foundation\\Http\\{closure}", "class": "Illuminate\\Foundation\\Http\\Kernel", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\barryvdh\\laravel-debugbar\\src\\Middleware\\InjectDebugbar.php", "line": 67, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 171, "function": "handle", "class": "Barryvdh\\Debugbar\\Middleware\\InjectDebugbar", "type": "->" }, { "file": "E:\\wwwroot\\object\\app\\Http\\Middleware\\ChangeAppUrlMiddleware.php", "line": 23, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 171, "function": "handle", "class": "App\\Http\\Middleware\\ChangeAppUrlMiddleware", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php", "line": 21, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 171, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php", "line": 21, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 171, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php", "line": 27, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 171, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php", "line": 63, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 171, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\fideloper\\proxy\\src\\TrustProxies.php", "line": 57, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 171, "function": "handle", "class": "Fideloper\\Proxy\\TrustProxies", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\dingo\\api\\src\\Http\\Middleware\\Request.php", "line": 111, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 171, "function": "handle", "class": "Dingo\\Api\\Http\\Middleware\\Request", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php", "line": 105, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php", "line": 145, "function": "then", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "E:\\wwwroot\\object\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php", "line": 110, "function": "sendRequestThroughRouter", "class": "Illuminate\\Foundation\\Http\\Kernel", "type": "->" }, { "file": "E:\\wwwroot\\object\\public\\index.php", "line": 57, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Kernel", "type": "->" } ] }
7、调整类 Modules\\OnlineStoreThemeGraphQL\\Resolver\\OnlineStoreTheme\\TemplateDetailsResolver 中的方法 __invoke。删除掉 yield 的循环。方法 __invoke 能够被执行到。如图3
public function __invoke($rootValue, array $args, GraphQLContext $context, ResolveInfo $resolveInfo) { echo 44; exit; $themeId = $rootValue['templateSettingsData']['theme_id']; $basename = $args['basename']; $rawSchemaLoader = $this->themeContext ->getThemeViewFactory() ->createRawSchemaLoader(); $rawSchemaLoaderAdapter = new RawSchemaLoaderAdapter($rawSchemaLoader); $sessionId = $rootValue['session_id']?? null; $rawSchemaLoaderAdapter->setSessionId($sessionId); try { $rawSchema = $rawSchemaLoaderAdapter->loadTemplateSchema($basename); $template = new Template(); $this->templateBuilder->build($rawSchema, $template); } catch(\Exception $e) { throw new GraphQlInputException($e->getMessage()); } $id = new Id([$themeId, $basename]); }
近期评论