Skip to content

@Security with External type declaration - error #546

Closed
@ameoba32

Description

@ameoba32

I am getting next error when using @Security with External type declaration.

Version: 5.0.3

"array_combine(): Argument #1 ($keys) and argument #2 ($values) must have the same number of elements"
vendor/thecodingmachine/graphqlite/src/Middlewares/SecurityFieldMiddleware.php:132

I've tried to debug the issue myself, it has something related with first parameter, which is always there. But no luck. If I comment out array_combine in SecurityFieldMiddleware.php:132 it seems to work.

Consider next php code example:

namespace App\Types;

use TheCodingMachine\GraphQLite\Annotations\Type;
use TheCodingMachine\GraphQLite\Annotations\Field;
use TheCodingMachine\GraphQLite\Annotations\Security;
use App\Entities\Product;

/**
 * @Type(class=Product::class)
 */
class ProductType
{
    /**
     * @Field
     * @Security("this.canAccess()")
     */
    public function getId(Product $product): string
    {
        return $product->getId();
    }
    
    public function canAccess(): bool
    {
        return true;
    }
}

thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions