ContextInterface.php 1.96 KB
Newer Older
Ketan's avatar
Ketan committed
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
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\Framework\GraphQl\Query\Resolver;

use Magento\Framework\Api\ExtensibleDataInterface;
use Magento\Framework\GraphQl\Query\ResolverInterface;

/**
 * Resolver Context is used as a shared data extensible object in all resolvers that implement @see ResolverInterface.
 *
 * GraphQL will pass the same instance of this interface to each field resolver, so these resolvers could have
 * shared access to the same data for ease of implementation purposes.
 */
interface ContextInterface extends ExtensibleDataInterface
{
    /**
     * Get the type of a user
     *
     * @see \Magento\Authorization\Model\UserContextInterface for corespondent values
     *
     * @return int
     */
    public function getUserType() : int;

    /**
     * Set type of a user
     *
     * @see \Magento\Authorization\Model\UserContextInterface for corespondent values
     *
     * @param int $typeId
     * @return ContextInterface
     */
    public function setUserType(int $typeId) : ContextInterface;

    /**
     * Get id of the user
     *
     * @return int
     */
    public function getUserId() : int;

    /**
     * Set id of a user
     *
     * @param int $userId
     * @return ContextInterface
     */
    public function setUserId(int $userId) : ContextInterface;

    /**
     * Retrieve existing extension attributes object or create a new one.
     *
     * @return \Magento\Framework\GraphQl\Query\Resolver\ContextExtensionInterface
     */
    public function getExtensionAttributes();

    /**
     * Set an extension attributes object.
     *
     * @param \Magento\Framework\GraphQl\Query\Resolver\ContextExtensionInterface $extensionAttributes
     * @return ContextInterface
     */
    public function setExtensionAttributes(
        \Magento\Framework\GraphQl\Query\Resolver\ContextExtensionInterface $extensionAttributes
    ) : ContextInterface;
}