0

I create custom graphql and have a error,please help me.

type Query {
    testSharingData (
        id: Int @doc(description: "The ID of the CMS page.")
    ): TestSharingData @resolver(class: "GlobalBq\\SharingGraphQl\\Model\\Resolver\\SharingItem") @doc(description: "Return details about a CMS page.")
}

type TestSharingData @doc(description: "SharingData defines the customer name and other details"){
    customer_id: Int
}

<?php
declare(strict_types=1);
namespace GlobalBq\SharingGraphQl\Model\Resolver;
use GlobalBq\SharingGraphQl\Model\ResourceModel\Sharing\Collection;
use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;

class SharingItem implements \Magento\Framework\GraphQl\Query\ResolverInterface
{
    /**
     * @var Collection
     */
    private Collection $collection;

    /**
     * @param Collection $collection
     */
    public function __construct(Collection $collection)
    {
        $this->collection = $collection;
    }

    /**
     * @inheritDoc
     */
    public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
    {

        $postData = [
            "customer_id" => 31
        ];
        return $postData;

    }
}

enter image description here

1 Answer 1

0

Try this

{
  testSharingData(id: [YOURID] ) {
    customer_id
  }
}
3
  • sorry ,my picture is wrong. My request just like this.
    – Allen
    Commented Jun 7, 2023 at 10:29
  • Please run upgrade and cache command and check it.
    – Msquare
    Commented Jun 7, 2023 at 10:32
  • Thank you very much. I only run setup:di:compile and clean cache, not run upgrade. it work for me.
    – Allen
    Commented Jun 7, 2023 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.