在 Laravel 6、Lighthouse 中,报错:Argument 1 passed to Nuwave\Lighthouse\Schema\TypeRegistry::get() must be of the type string, array given
1、报错:Argument 1 passed to App\\Exceptions\\Handler::report() must be an instance of Exception, instance of TypeError given, called in E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Execution\\ReportingErrorHandler.php on line 40。如图1
{ "message": "Argument 1 passed to App\\Exceptions\\Handler::report() must be an instance of Exception, instance of TypeError given, called in E:\\wwwroot\\object\\vendor\\nuwave\\lighthouse\\src\\Execution\\ReportingErrorHandler.php on line 40", "exception": "Symfony\\Component\\Debug\\Exception\\FatalThrowableError", "file": "E:\\wwwroot\\object\\app\\Exceptions\\Handler.php", "line": 42, "trace": [ ... ] }
2、参考网址:https://www.shuijingwanwq.com/2022/01/26/5827/ 。版本兼容问题所导致。编辑 /vendor/nuwave/lighthouse/src/Execution/ReportingErrorHandler.php。打印 $error。message:Argument 1 passed to Nuwave\Lighthouse\Schema\TypeRegistry::get() must be of the type string, array given, called in E:\wwwroot\object\vendor\nuwave\lighthouse\src\Schema\TypeRegistry.php on line 542。如图2
GraphQL\Error\Error {#11984 -locations: array:1 [ 0 => GraphQL\Language\SourceLocation {#11586 +line: 185 +column: 7 } ] +path: array:8 [ 0 => "onlineStoreTheme" 1 => "current" 2 => "sections" 3 => 2 4 => "blocks" 5 => 0 6 => "settings" 7 => 0 ] +nodes: array:1 [ 0 => GraphQL\Language\AST\FieldNode {#3995 +kind: "Field" +name: GraphQL\Language\AST\NameNode {#3996 +kind: "Name" +value: "settings" +loc: GraphQL\Language\AST\Location {#3997 +start: 2556 +end: 2564 +startToken: GraphQL\Language\Token {#2908 +kind: "Name" +start: 2556 +end: 2564 +line: 185 +column: 7 +value: "settings" +prev: GraphQL\Language\Token {#2907 +kind: "Name" +start: 2545 +end: 2549 +line: 184 +column: 7 +value: "type" +prev: GraphQL\Language\Token {#2906 +kind: "Name" +start: 2530 +end: 2538 +line: 183 +column: 7 +value: "disabled" +prev: GraphQL\Language\Token {#2905 +kind: "Name" +start: 2516 +end: 2523 +line: 182 +column: 7 +value: "blockId" +prev: GraphQL\Language\Token {#2904 +kind: "Name" +start: 2507 +end: 2509 +line: 181 +column: 7 +value: "id" +prev: GraphQL\Language\Token {#2903 +kind: "{" +start: 2499 +end: 2500 +line: 180 +column: 12 +value: null +prev: GraphQL\Language\Token {#2902 +kind: "Name" +start: 2492 +end: 2498 +line: 180 +column: 5 +value: "blocks" +prev: GraphQL\Language\Token {#2901 +kind: "Name" +start: 2477 +end: 2487 +line: 179 +column: 5 +value: "blockOrder" +prev: GraphQL\Language\Token {#2900 +kind: "Name" +start: 2468 +end: 2472 +line: 178 +column: 5 +value: "type" +prev: GraphQL\Language\Token {#2899 +kind: "}" +start: 2462 +end: 2463 +line: 177 +column: 5 +value: null +prev: GraphQL\Language\Token {#2898 +kind: "Name" +start: 2453 +end: 2457 +line: 176 +column: 7 +value: "type" +prev: GraphQL\Language\Token {#2897 +kind: "Name" +start: 2441 +end: 2446 +line: 175 +column: 7 +value: "value" +prev: GraphQL\Language\Token {#2896 +kind: "Name" +start: 2425 +end: 2434 +line: 174 +column: 7 +value: "settingId" +prev: GraphQL\Language\Token {#2895 +kind: "Name" +start: 2416 +end: 2418 +line: 173 +column: 7 +value: "id" +prev: GraphQL\Language\Token {#2894 +kind: "{" +start: 2408 +end: 2409 +line: 172 +column: 14 +value: null +prev: GraphQL\Language\Token {#2893 …8} +next: GraphQL\Language\Token {#2895} } +next: GraphQL\Language\Token {#2896} } +next: GraphQL\Language\Token {#2897} } +next: GraphQL\Language\Token {#2898} } +next: GraphQL\Language\Token {#2899} } +next: GraphQL\Language\Token {#2900} } +next: GraphQL\Language\Token {#2901} } +next: GraphQL\Language\Token {#2902} } +next: GraphQL\Language\Token {#2903} } +next: GraphQL\Language\Token {#2904} } +next: GraphQL\Language\Token {#2905} } +next: GraphQL\Language\Token {#2906} } +next: GraphQL\Language\Token {#2907} } +next: GraphQL\Language\Token {#2908} } +next: GraphQL\Language\Token {#2909 +kind: "{" +start: 2565 +end: 2566 +line: 185 +column: 16 +value: null +prev: GraphQL\Language\Token {#2908} +next: GraphQL\Language\Token {#2910 +kind: "Name" +start: 2575 +end: 2577 +line: 186 +column: 9 +value: "id" +prev: GraphQL\Language\Token {#2909} +next: GraphQL\Language\Token {#2911 +kind: "Name" +start: 2586 +end: 2590 +line: 187 +column: 9 +value: "info" +prev: GraphQL\Language\Token {#2910} +next: GraphQL\Language\Token {#2912 +kind: "Name" +start: 2599 +end: 2604 +line: 188 +column: 9 +value: "label" +prev: GraphQL\Language\Token {#2911} +next: GraphQL\Language\Token {#2913 +kind: "Name" +start: 2613 +end: 2622 +line: 189 +column: 9 +value: "settingId" +prev: GraphQL\Language\Token {#2912} +next: GraphQL\Language\Token {#2914 +kind: "Name" +start: 2631 +end: 2635 +line: 190 +column: 9 +value: "type" +prev: GraphQL\Language\Token {#2913} +next: GraphQL\Language\Token {#2915 +kind: "}" +start: 2642 +end: 2643 +line: 191 +column: 7 +value: null +prev: GraphQL\Language\Token {#2914} +next: GraphQL\Language\Token {#2916 +kind: "}" +start: 2648 +end: 2649 +line: 192 +column: 5 +value: null +prev: GraphQL\Language\Token {#2915} +next: GraphQL\Language\Token {#2917 +kind: "}" +start: 2652 +end: 2653 +line: 193 +column: 3 +value: null +prev: GraphQL\Language\Token {#2916} +next: GraphQL\Language\Token {#2918 +kind: "}" +start: 2654 +end: 2655 +line: 194 +column: 1 +value: null +prev: GraphQL\Language\Token {#2917} +next: GraphQL\Language\Token {#2919 +kind: "Name" +start: 2657 +end: 2665 +line: 196 +column: 1 +value: "fragment" +prev: GraphQL\Language\Token {#2918} +next: GraphQL\Language\Token {#2920 +kind: "Name" +start: 2666 +end: 2684 +line: 196 +column: 10 +value: "themeSectionSchema" +prev: GraphQL\Language\Token {#2919} +next: GraphQL\Language\Token {#2921 +kind: "Name" +start: 2685 +end: 2687 +line: 196 +column: 29 +value: "on" +prev: GraphQL\Language\Token {#2920} +next: GraphQL\Language\Token {#2922 +kind: "Name" +start: 2688 +end: 2700 +line: 196 +column: 32 +value: "ThemeSection" +prev: GraphQL\Language\Token {#2921} +next: GraphQL\Language\Token {#2923 …8} } } } } } } } } } } } } } } } +endToken: GraphQL\Language\Token {#2908} +source: GraphQL\Language\Source {#2959 +body: """ { onlineStoreTheme(themeId: "theme") { id editable createdAt publishAt name metadata { id author description documentationUrl logoUrl name supportEmail supportUrl version } presets { id settings { id settingId value type } ...sections } current { id settings { id settingId value type } ...sections } sectionSchemas { blockSchemas { id limit name settings { id info label settingId type } type } blocksLimit hasPresets id limit maxBlocks name settings { id info label settingId type } type } themeSettingsCategories { id settings { id info label settingId type } title } templateSettingsData(basename: "index") { id sectionId disabled ...themeSectionSchema settings { id settingId value type } type blockOrder blocks { id blockId disabled type settings { id info label settingId type } } } themeAssetList { themeId name key creatable themeAssetKeys } themeAssetVersions(key: "string") { code key version createdAt contentType } themeAsset(key: "string") { id themeId content key mimeType category schema createdAt updatedAt deletable renameable updatable } } } fragment sections on ThemePreset { sections { id sectionId disabled schema { blockSchemas { id limit name settings { id info label settingId type } type } blocksLimit hasPresets id limit maxBlocks name settings { id info label settingId type } type } settings { id settingId value type } type blockOrder blocks { id blockId disabled type settings { id info label settingId type } } } } fragment themeSectionSchema on ThemeSection { schema { blockSchemas { id limit name settings { id info label settingId type } type } blocksLimit hasPresets id limit maxBlocks name settings { id info label settingId type } type } } """ +length: 3041 +name: "GraphQL request" +locationOffset: GraphQL\Language\SourceLocation {#2960 +line: 1 +column: 1 } } } } +alias: null +arguments: GraphQL\Language\AST\NodeList {#3998 -nodes: [] } +directives: GraphQL\Language\AST\NodeList {#3999 -nodes: [] } +selectionSet: GraphQL\Language\AST\SelectionSetNode {#4000 +kind: "SelectionSet" +selections: GraphQL\Language\AST\NodeList {#4001 -nodes: array:5 [ 0 => GraphQL\Language\AST\FieldNode {#4002 +kind: "Field" +name: GraphQL\Language\AST\NameNode {#4003 +kind: "Name" +value: "id" +loc: GraphQL\Language\AST\Location {#4004 +start: 2575 +end: 2577 +startToken: GraphQL\Language\Token {#2910} +endToken: GraphQL\Language\Token {#2910} +source: GraphQL\Language\Source {#2959} } } +alias: null +arguments: GraphQL\Language\AST\NodeList {#4005 -nodes: [] } +directives: GraphQL\Language\AST\NodeList {#4006 -nodes: [] } +selectionSet: null +loc: GraphQL\Language\AST\Location {#4007 +start: 2575 +end: 2577 +startToken: GraphQL\Language\Token {#2910} +endToken: GraphQL\Language\Token {#2910} +source: GraphQL\Language\Source {#2959} } } 1 => GraphQL\Language\AST\FieldNode {#4008 +kind: "Field" +name: GraphQL\Language\AST\NameNode {#4009 +kind: "Name" +value: "info" +loc: GraphQL\Language\AST\Location {#4010 +start: 2586 +end: 2590 +startToken: GraphQL\Language\Token {#2911} +endToken: GraphQL\Language\Token {#2911} +source: GraphQL\Language\Source {#2959} } } +alias: null +arguments: GraphQL\Language\AST\NodeList {#4011 -nodes: [] } +directives: GraphQL\Language\AST\NodeList {#4012 -nodes: [] } +selectionSet: null +loc: GraphQL\Language\AST\Location {#4013 +start: 2586 +end: 2590 +startToken: GraphQL\Language\Token {#2911} +endToken: GraphQL\Language\Token {#2911} +source: GraphQL\Language\Source {#2959} } } 2 => GraphQL\Language\AST\FieldNode {#4014 +kind: "Field" +name: GraphQL\Language\AST\NameNode {#4015 +kind: "Name" +value: "label" +loc: GraphQL\Language\AST\Location {#4016 +start: 2599 +end: 2604 +startToken: GraphQL\Language\Token {#2912} +endToken: GraphQL\Language\Token {#2912} +source: GraphQL\Language\Source {#2959} } } +alias: null +arguments: GraphQL\Language\AST\NodeList {#4017 -nodes: [] } +directives: GraphQL\Language\AST\NodeList {#4018 -nodes: [] } +selectionSet: null +loc: GraphQL\Language\AST\Location {#4019 +start: 2599 +end: 2604 +startToken: GraphQL\Language\Token {#2912} +endToken: GraphQL\Language\Token {#2912} +source: GraphQL\Language\Source {#2959} } } 3 => GraphQL\Language\AST\FieldNode {#4020 +kind: "Field" +name: GraphQL\Language\AST\NameNode {#4021 +kind: "Name" +value: "settingId" +loc: GraphQL\Language\AST\Location {#4022 +start: 2613 +end: 2622 +startToken: GraphQL\Language\Token {#2913} +endToken: GraphQL\Language\Token {#2913} +source: GraphQL\Language\Source {#2959} } } +alias: null +arguments: GraphQL\Language\AST\NodeList {#4023 -nodes: [] } +directives: GraphQL\Language\AST\NodeList {#4024 -nodes: [] } +selectionSet: null +loc: GraphQL\Language\AST\Location {#4025 +start: 2613 +end: 2622 +startToken: GraphQL\Language\Token {#2913} +endToken: GraphQL\Language\Token {#2913} +source: GraphQL\Language\Source {#2959} } } 4 => GraphQL\Language\AST\FieldNode {#4026 +kind: "Field" +name: GraphQL\Language\AST\NameNode {#4027 +kind: "Name" +value: "type" +loc: GraphQL\Language\AST\Location {#4028 +start: 2631 +end: 2635 +startToken: GraphQL\Language\Token {#2914} +endToken: GraphQL\Language\Token {#2914} +source: GraphQL\Language\Source {#2959} } } +alias: null +arguments: GraphQL\Language\AST\NodeList {#4029 -nodes: [] } +directives: GraphQL\Language\AST\NodeList {#4030 -nodes: [] } +selectionSet: null +loc: GraphQL\Language\AST\Location {#4031 +start: 2631 +end: 2635 +startToken: GraphQL\Language\Token {#2914} +endToken: GraphQL\Language\Token {#2914} +source: GraphQL\Language\Source {#2959} } } ] } +loc: GraphQL\Language\AST\Location {#4032 +start: 2565 +end: 2643 +startToken: GraphQL\Language\Token {#2909} +endToken: GraphQL\Language\Token {#2915} +source: GraphQL\Language\Source {#2959} } } +loc: GraphQL\Language\AST\Location {#4033 +start: 2556 +end: 2643 +startToken: GraphQL\Language\Token {#2908} +endToken: GraphQL\Language\Token {#2915} +source: GraphQL\Language\Source {#2959} } } ] -source: GraphQL\Language\Source {#2959} -positions: array:1 [ 0 => 2556 ] -isClientSafe: false #category: "internal" #extensions: [] #message: "Argument 1 passed to Nuwave\Lighthouse\Schema\TypeRegistry::get() must be of the type string, array given, called in E:\wwwroot\object\vendor\nuwave\lighthouse\src\Schema\TypeRegistry.php on line 542" #code: 0 #file: "E:\wwwroot\object\vendor\webonyx\graphql-php\src\Error\Error.php" #line: 176 -previous: TypeError {#9336 #message: "Argument 1 passed to Nuwave\Lighthouse\Schema\TypeRegistry::get() must be of the type string, array given, called in E:\wwwroot\object\vendor\nuwave\lighthouse\src\Schema\TypeRegistry.php on line 542" #code: 0 #file: "E:\wwwroot\object\vendor\nuwave\lighthouse\src\Schema\TypeRegistry.php" #line: 123 trace: { E:\wwwroot\object\vendor\nuwave\lighthouse\src\Schema\TypeRegistry.php:123 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\Schema\TypeRegistry.php:542 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Type\Definition\InterfaceType.php:130 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:940 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:789 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:741 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:654 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:887 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:761 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:741 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:654 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:557 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1195 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1145 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1106 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:793 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:741 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:654 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:887 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:761 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:741 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:654 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:557 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1195 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1145 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1106 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:793 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:741 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:654 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:887 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:761 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:741 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:654 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:557 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1195 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1145 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1106 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:793 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:741 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:654 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:557 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1195 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1145 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1106 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:793 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:654 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:557 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1195 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:264 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:215 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\Executor.php:156 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\GraphQL.php:162 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\GraphQL.php:94 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\GraphQL.php:268 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\GraphQL.php:203 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\GraphQL.php:162 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\GraphQL.php:121 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\Support\Utils.php:99 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\GraphQL.php:120 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\Support\Http\Controllers\GraphQLController.php:32 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php:48 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Routing\Route.php:219 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Routing\Route.php:176 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Routing\Router.php:681 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:130 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\Support\Http\Middleware\AttemptAuthentication.php:34 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\Support\Http\Middleware\AcceptJson.php:27 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:105 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Routing\Router.php:683 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Routing\Router.php:658 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Routing\Router.php:624 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Routing\Router.php:613 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:170 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:130 {} E:\wwwroot\object\vendor\barryvdh\laravel-debugbar\src\Middleware\InjectDebugbar.php:67 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\app\Http\Middleware\ChangeAppUrlMiddleware.php:23 { App\Http\Middleware\ChangeAppUrlMiddleware->handle($request, Closure $next) … › } › return $next($request); › } arguments: { Illuminate\Http\Request {#53 …} } } E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php:21 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php:21 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ValidatePostSize.php:27 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php:63 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\vendor\fideloper\proxy\src\TrustProxies.php:57 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\vendor\dingo\api\src\Http\Middleware\Request.php:111 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:105 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:145 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:110 {} E:\wwwroot\object\public\index.php:57 {} } } trace: { E:\wwwroot\object\vendor\webonyx\graphql-php\src\Error\Error.php:176 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:681 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:666 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:887 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:761 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:741 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:654 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:557 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1195 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1145 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1106 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:793 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:741 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:654 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:887 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:761 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:741 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:654 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:557 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1195 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1145 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1106 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:793 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:741 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:654 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:887 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:761 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:741 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:654 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:557 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1195 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1145 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1106 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:793 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:741 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:654 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:557 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1195 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1145 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1106 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:793 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:654 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:557 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:1195 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:264 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\ReferenceExecutor.php:215 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\Executor\Executor.php:156 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\GraphQL.php:162 {} E:\wwwroot\object\vendor\webonyx\graphql-php\src\GraphQL.php:94 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\GraphQL.php:268 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\GraphQL.php:203 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\GraphQL.php:162 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\GraphQL.php:121 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\Support\Utils.php:99 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\GraphQL.php:120 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\Support\Http\Controllers\GraphQLController.php:32 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php:48 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Routing\Route.php:219 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Routing\Route.php:176 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Routing\Router.php:681 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:130 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\Support\Http\Middleware\AttemptAuthentication.php:34 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\vendor\nuwave\lighthouse\src\Support\Http\Middleware\AcceptJson.php:27 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:105 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Routing\Router.php:683 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Routing\Router.php:658 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Routing\Router.php:624 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Routing\Router.php:613 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:170 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:130 {} E:\wwwroot\object\vendor\barryvdh\laravel-debugbar\src\Middleware\InjectDebugbar.php:67 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\app\Http\Middleware\ChangeAppUrlMiddleware.php:23 { App\Http\Middleware\ChangeAppUrlMiddleware->handle($request, Closure $next) … › } › return $next($request); › } arguments: { Illuminate\Http\Request {#53 …} } } E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php:21 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php:21 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ValidatePostSize.php:27 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php:63 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\vendor\fideloper\proxy\src\TrustProxies.php:57 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\vendor\dingo\api\src\Http\Middleware\Request.php:111 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:171 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:105 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:145 {} E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:110 {} E:\wwwroot\object\public\index.php:57 {} } }
3、编辑 /vendor/nuwave/lighthouse/src/Schema/TypeRegistry.php,打印 $name。确定其中一个参数的格式为数组。如图3
/** * Get the given GraphQL type by name. * * @throws \Nuwave\Lighthouse\Exceptions\DefinitionException */ public function get($name): Type { var_dump($name); if (! $this->has($name)) { throw self::failedToLoadType($name); } return $this->types[$name]; }
string(20) "ThemeSettingCheckbox" string(10) "ThemeBlock" array(4) { ["id"]=> object(Modules\ThemeStore\Resolver\Id)#11271 (1) { ["prefixes":protected]=> array(5) { [0]=> string(8) "theme" [1]=> string(7) "current" [2]=> string(16) "announcement-bar" [3]=> string(18) "announcement-bar-0" [4]=> string(5) "style" } } ["settingId"]=> string(5) "style" ["value"]=> string(4) "text" ["type"]=> string(12) "announcement" }
4、当删除 settings 后,不再报此错误。如图4
5、分别找到 2 个 settings 字段,皆是 [ThemeSetting!]! 类型。查找代码实现上的差异。可以确定报错的字段并非 [ThemeSetting!]! 类型。
'blockSchemas' => collect($section->getBlocks())->map(function(Block $block, $blockId) use ($id){ $id = $id->with('blockSchemas'); return [ 'id' => $id->with($blockId), 'blockId' => $blockId, 'limit' => $block->getLimit(), 'name' => $block->getName(), 'type' => $block->getType(), 'settings' => collect($block->getSettings())->map(function(BaseType $type, $index) use ($id) { return $this->resolveSettingType($type, $id->with('settings'), $index); }) ]; }),
'blocks' => collect($sectionSetting->getBlocks()) ->map(function(BlockSetting $block, $blockId) use ($sectionSchema, $globalSectionId){ $globalBlockId = $globalSectionId->with($blockId); return [ 'id' => $globalBlockId, 'blockId' => $blockId, 'disabled' => $block->isDisabled(), 'type' => $block->getType(), 'settings' => collect($block->getSettings())->map(function($value, $id) use($sectionSchema, $block, $globalBlockId){ return [ 'id' => $globalBlockId->with($id), 'settingId' => $id, 'value' => $value, 'type' => $sectionSchema->getBlock($block->getType())->getType() ]; }), ]; })
6、分别打印正确与错误的 dd($block->getSettings());。再次确证错误的字段并非 ThemeSetting。如图5
array:9 [ 0 => Modules\ThemeSetting\Schema\Types\SelectType {#11172 -multiple: false -options: array:2 [ 0 => array:2 [ "value" => "text" "label" => "使用文本" ] 1 => array:2 [ "value" => "image" "label" => "使用图片" ] ] -id: "style" -label: "内容显示" -info: null -default: "text" -type: "select" } 1 => Modules\ThemeSetting\Schema\Types\TextType {#11169 -heading: null -subtext: null -placeHolder: null -id: "text" -label: "Text" -info: null -default: "Welcome to our store" -type: "text" } 2 => Modules\ThemeSetting\Schema\Types\SelectType {#11173 -multiple: false -options: array:5 [ 0 => array:2 [ "value" => "background-1" "label" => "背景色 1" ] 1 => array:2 [ "value" => "background-2" "label" => "背景色 2" ] 2 => array:2 [ "value" => "inverse" "label" => "反转" ] 3 => array:2 [ "value" => "accent-1" "label" => "强调色 1" ] 4 => array:2 [ "value" => "accent-2" "label" => "强调色 2" ] ] -id: "color_scheme" -label: "配色方案" -info: null -default: "background-1" -type: "select" } 3 => Modules\ThemeSetting\Schema\Types\CheckboxType {#11171 -id: "gradient" -label: "Gradient" -info: null -default: false -type: "checkbox" } 4 => Modules\ThemeSetting\Schema\Types\UrlType {#11174 -id: "link" -label: "Link" -info: null -default: null -type: "url" } 5 => Modules\ThemeSetting\Schema\Types\ImagePickerType {#11175 -id: "image" -label: "电脑端图片" -info: null -default: null -type: "image_picker" } 6 => Modules\ThemeSetting\Schema\Types\ImagePickerType {#11176 -id: "mobile_image" -label: "移动端图片" -info: null -default: null -type: "image_picker" } 7 => Modules\ThemeSetting\Schema\Types\ColorType {#11177 -id: "text_color" -label: "文字颜色" -info: null -default: null -type: "color" } 8 => Modules\ThemeSetting\Schema\Types\ColorType {#11178 -id: "background_color" -label: "背景颜色" -info: null -default: null -type: "color" } ]
array:9 [ "style" => "text" "text" => null "color_scheme" => "inverse" "gradient" => null "link" => "/" "image" => null "mobile_image" => null "text_color" => "white" "background_color" => "#000000" ]
7、编辑 /Modules/ThemeStore/Resources/graphql/theme_setting.graphql。因为代码实现的是类型 [ThemeStyleSetting!]。
编辑前:
type ThemeBlock { id: ID! blockId: String! "Whether the block is disabled." disabled: Boolean! type: String! settings: [ThemeSetting!]! }
编辑后:
type ThemeBlock { id: ID! blockId: String! "Whether the block is disabled." disabled: Boolean! type: String! settings: [ThemeStyleSetting!] }
8、请求响应 200。如图6
近期评论