thecodingmachine / graphqlite

Use PHP Attributes/Annotations to declare your GraphQL API
https://graphqlite.thecodingmachine.io
MIT License
554 stars 95 forks source link

How to debug errors? #647

Closed michilehr closed 6 months ago

michilehr commented 6 months ago

Hi,

currently, I am facing following Error

Typed property TheCodingMachine\GraphQLite\InputFieldDescriptor::$targetMethodOnSource must not be accessed before initialization

How to debug this best?

oojacoboo commented 6 months ago

You start with a full stack trace.

michilehr commented 6 months ago

Hi @oojacoboo ,

Thank you for your reply.

Sorry - forgot to mention that the stack trace was not really helpful.

Error:
Typed property TheCodingMachine\GraphQLite\InputFieldDescriptor::$targetMethodOnSource must not be accessed before initialization

  at vendor/thecodingmachine/graphqlite/src/InputFieldDescriptor.php:236
  at TheCodingMachine\GraphQLite\InputFieldDescriptor->getOriginalResolver()
     (vendor/thecodingmachine/graphqlite/src/InputField.php:131)
  at TheCodingMachine\GraphQLite\InputField::fromDescriptor()
     (vendor/thecodingmachine/graphqlite/src/InputField.php:148)
  at TheCodingMachine\GraphQLite\InputField::fromFieldDescriptor()
     (vendor/thecodingmachine/graphqlite/src/FieldsBuilder.php:900)
  at TheCodingMachine\GraphQLite\Middlewares\InputFieldHandlerInterface@anonymous/var/www/html/vendor/thecodingmachine/graphqlite/src/FieldsBuilder.php:897$554ae->handle()
     (vendor/thecodingmachine/graphqlite/src/Middlewares/InputNext.php:34)
  at TheCodingMachine\GraphQLite\Middlewares\InputNext->handle()
     (vendor/thecodingmachine/graphqlite/src/Middlewares/AuthorizationInputFieldMiddleware.php:41)
  at TheCodingMachine\GraphQLite\Middlewares\AuthorizationInputFieldMiddleware->process()
     (vendor/thecodingmachine/graphqlite/src/Middlewares/InputNext.php:39)
  at TheCodingMachine\GraphQLite\Middlewares\InputNext->handle()
     (vendor/thecodingmachine/graphqlite/src/Middlewares/SecurityInputFieldMiddleware.php:41)
  at TheCodingMachine\GraphQLite\Middlewares\SecurityInputFieldMiddleware->process()
     (vendor/thecodingmachine/graphqlite/src/Middlewares/InputNext.php:39)
  at TheCodingMachine\GraphQLite\Middlewares\InputNext->handle()
     (vendor/thecodingmachine/graphqlite/src/Middlewares/InputFieldMiddlewarePipe.php:31)
  at TheCodingMachine\GraphQLite\Middlewares\InputFieldMiddlewarePipe->process()
     (vendor/thecodingmachine/graphqlite/src/FieldsBuilder.php:897)
  at TheCodingMachine\GraphQLite\FieldsBuilder->getInputFieldsByMethodAnnotations()
     (vendor/thecodingmachine/graphqlite/src/FieldsBuilder.php:170)
  at TheCodingMachine\GraphQLite\FieldsBuilder->getInputFields()
     (vendor/thecodingmachine/graphqlite/src/Types/InputType.php:40)
  at TheCodingMachine\GraphQLite\Types\InputType->TheCodingMachine\GraphQLite\Types\{closure}()
     (vendor/webonyx/graphql-php/src/Type/Definition/InputObjectType.php:113)
  at GraphQL\Type\Definition\InputObjectType->initializeFields()
     (vendor/webonyx/graphql-php/src/Type/Definition/InputObjectType.php:102)
  at GraphQL\Type\Definition\InputObjectType->getFields()
     (vendor/thecodingmachine/graphqlite/src/Types/MutableInputObjectType.php:90)
  at TheCodingMachine\GraphQLite\Types\MutableInputObjectType->getFields()
     (vendor/webonyx/graphql-php/src/Utils/TypeInfo.php:129)
  at GraphQL\Utils\TypeInfo::extractTypes()
     (vendor/webonyx/graphql-php/src/Type/Schema.php:149)
  at GraphQL\Type\Schema->getTypeMap()
     (vendor/webonyx/graphql-php/src/Type/Introspection.php:267)
  at GraphQL\Type\Introspection::GraphQL\Type\{closure}()
     (vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:714)
  at GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError()
     (vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:631)
  at GraphQL\Executor\ReferenceExecutor->resolveField()
     (vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:1317)
  at GraphQL\Executor\ReferenceExecutor->executeFields()
     (vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:1256)
  at GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields()
     (vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:1210)
  at GraphQL\Executor\ReferenceExecutor->completeObjectValue()
     (vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:893)
  at GraphQL\Executor\ReferenceExecutor->completeValue()
     (vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:844)
  at GraphQL\Executor\ReferenceExecutor->completeValue()
     (vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:753)
  at GraphQL\Executor\ReferenceExecutor->completeValueCatchingError()
     (vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:640)
  at GraphQL\Executor\ReferenceExecutor->resolveField()
     (vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:1317)
  at GraphQL\Executor\ReferenceExecutor->executeFields()
     (vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:298)
  at GraphQL\Executor\ReferenceExecutor->executeOperation()
     (vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php:237)
  at GraphQL\Executor\ReferenceExecutor->doExecute()
     (vendor/webonyx/graphql-php/src/Executor/Executor.php:159)
  at GraphQL\Executor\Executor::promiseToExecute()
     (vendor/webonyx/graphql-php/src/GraphQL.php:162)
  at GraphQL\GraphQL::promiseToExecute()
     (vendor/webonyx/graphql-php/src/Server/Helper.php:279)
  at GraphQL\Server\Helper->promiseToExecuteOperation()
     (vendor/webonyx/graphql-php/src/Server/Helper.php:187)
  at GraphQL\Server\Helper->executeOperation()
     (vendor/webonyx/graphql-php/src/Server/StandardServer.php:119)
  at GraphQL\Server\StandardServer->executeRequest()
     (vendor/webonyx/graphql-php/src/Server/StandardServer.php:166)
  at GraphQL\Server\StandardServer->executePsrRequest()
     (vendor/thecodingmachine/graphqlite-bundle/Controller/GraphQLiteController.php:109)
  at TheCodingMachine\GraphQLite\Bundle\Controller\GraphQLiteController->handlePsr7Request()
     (vendor/thecodingmachine/graphqlite-bundle/Controller/GraphQLiteController.php:99)
  at TheCodingMachine\GraphQLite\Bundle\Controller\GraphQLiteController->handleRequest()
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:181)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw()
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:76)
  at Symfony\Component\HttpKernel\HttpKernel->handle()
     (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:197)
  at Symfony\Component\HttpKernel\Kernel->handle()
     (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35)
  at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run()
     (vendor/autoload_runtime.php:29)
  at require_once('/var/www/html/vendor/autoload_runtime.php')
     (web/app_dev.php:5)  

I did debug the InputFieldDescriptor on nameand found out that there was a problem with a class (a type) which was used in an InputType (which is also a Type) and the property and also the setter were defined as Field. Setting the Field attribute to property only removed the duplicate definiton.

Problem is that this occured after the update to v6 from v5 - before it worked somehow.