Skip to content

Nuwave\\Lighthouse\\Execution\\Arguments\\Argument::$type unable to set required Argument type property. #2681

Closed
@Steart

Description

@Steart

Describe the bug
The vendor/nuwave/lighthouse/src/Validation/Validator.php validator has the public setArgs method that can be used to add an ArgumentSet to the args pre validation.
Making it possible to retrieve a model and validate its content in certain cases.

There is no way to set the Type property on the Argument that is used in the ArgumentSet which is required by the RulesGatherer class.
This causes the following error to occur:
"debugMessage": "Typed property Nuwave\\Lighthouse\\Execution\\Arguments\\Argument::$type must not be accessed before initialization",
Expected behavior/Solution
Either to be able to set the types manually set it or some sort of parser that resolvers it automatically.

The above(Expected behavior/Solution) answers this question.

Steps to reproduce

  1. Have an input with the @validator directive
  2. Inside the Validator make use of the prepareForValidation method.
  3. Store $args = $this->args in a local variable and set a value, using the $this->args->addValue() method.
  4. Call $this->setArgs($args); this should raise the error.

Output/Logs
"extensions": { "debugMessage": "Typed property Nuwave\\Lighthouse\\Execution\\Arguments\\Argument::$type must not be accessed before initialization", "file": "/var/www/test/vendor/nuwave/lighthouse/src/Validation/RulesGatherer.php", "line": 63, "trace": [ { "file": "/var/www/test/vendor/nuwave/lighthouse/src/Validation/RulesGatherer.php", "line": 43, "call": "Nuwave\\Lighthouse\\Validation\\RulesGatherer::gatherRulesRecursively(instance of Nuwave\\Lighthouse\\Execution\\Arguments\\ArgumentSet, array(0))" }, { "file": "/var/www/test/vendor/nuwave/lighthouse/src/Validation/ValidateDirective.php", "line": 29, "call": "Nuwave\\Lighthouse\\Validation\\RulesGatherer::__construct(instance of Nuwave\\Lighthouse\\Execution\\Arguments\\ArgumentSet)" }, { "file": "/var/www/test/vendor/nuwave/lighthouse/src/Schema/Values/FieldValue.php", "line": 175, "call": "Nuwave\\Lighthouse\\Validation\\ValidateDirective::Nuwave\\Lighthouse\\Validation\\{closure}(instance of Nuwave\\Lighthouse\\Execution\\Arguments\\ArgumentSet, instance of GraphQL\\Type\\Definition\\ResolveInfo)" }, { "file": "/var/www/test/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php", "line": 714, "call": "Nuwave\\Lighthouse\\Schema\\Values\\FieldValue::Nuwave\\Lighthouse\\Schema\\Values\\{closure}(null, array(1), instance of Nuwave\\Lighthouse\\Execution\\HttpGraphQLContext, instance of GraphQL\\Type\\Definition\\ResolveInfo)"

Click to expand
# Add in log output/error messages here

Lighthouse Version
6.36.0, tried with version 6.56.0 but that didn't make a difference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error within Lighthouse

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions