在 Lighthouse 中,resolver 所对应的类方法 __invoke 未执行的排查分析
1、GraphQL 架构定义如下
1 2 3 4 5 6 7 | "获取主题页面的配置" templateDetails(basename: String!): OnlineStoreThemeTemplateDetails @field(resolver: "Modules\\OnlineStoreThemeGraphQL\\Resolver\\OnlineStoreTheme\\TemplateDetailsResolver") type OnlineStoreThemeTemplateDetails { sectionsData: [OnlineStoreThemeSection] sectionSchemas: [OnlineStoreThemeSectionSchema] } |
2、在类 TemplateDetailsResolver 中方法 __invoke 中打印输出 1,未输出。如图1
1 2 3 4 5 | public function __invoke( $rootValue , array $args , GraphQLContext $context , ResolveInfo $resolveInfo ) { echo 1; exit ; } |
1 2 3 4 | "templateDetails": { "sectionsData": null, "sectionSchemas": null }, |
3、GraphQL 架构定义还原如下,则对应的类方法 __invoke 能够执行到。如图2
1 2 3 4 5 6 7 | "获取主题页面的配置" templateDetails(basename: String!): [OnlineStoreThemeSection] @field(resolver: "Modules\\OnlineStoreThemeGraphQL\\Resolver\\OnlineStoreTheme\\TemplateDetailsResolver") type OnlineStoreThemeTemplateDetails { sectionsData: [OnlineStoreThemeSection] sectionSchemas: [OnlineStoreThemeSectionSchema] } |
4、决定拆分 GraphQL 架构定义,则对应的类方法 __invoke 能够执行到。
1 2 3 4 5 6 7 | "获取主题页面的配置" templateDetails(basename: String!): OnlineStoreThemeTemplateDetails type OnlineStoreThemeTemplateDetails { sectionsData: [OnlineStoreThemeSection] @field(resolver: "Modules\\OnlineStoreThemeGraphQL\\Resolver\\OnlineStoreTheme\\TemplateDetailsResolver") sectionSchemas: [OnlineStoreThemeSectionSchema] } |
5、GraphQL 架构定义调整解析类,则对应的类方法 __invoke 能够执行到。确认问题根源在于解析类本身。
1 2 3 4 5 6 7 | "获取主题页面的配置" 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)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | <?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 ; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | <?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 ); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 | { "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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 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 ]); } |
近期评论