Giter VIP home page Giter VIP logo

Comments (6)

PowerKiKi avatar PowerKiKi commented on June 3, 2024

There is no requirement for default filtering. It should work out of the box. Your code seems to be correct...

I am not sure when the error happen. When you run a query ? which one ?

You should try validating your schema (in your unit tests) with the \GraphQL\Type\Schema::assertValid()

from graphql-doctrine.

popovserhii avatar popovserhii commented on June 3, 2024

@PowerKiKi, thanks for a quick response

I've added \GraphQL\Type\Schema::assertValid() for assert schema and this is thrown exception Input Object type MarketplaceFilterGroupJoin must define one or more fields.

Here is simple setup of GraphQL Server:

$types = new Types($this->entityManager, $this->container);

// Configure default field resolver to be able to use getters
GraphQL::setDefaultFieldResolver(new DefaultFieldResolver());

try {
    $queryType = new ObjectType([
        'name' => 'query',
        'fields' => [
            'marketplaces' => [
                'type' => Type::listOf($types->getOutput(Marketplace::class)), // Use automated ObjectType for output
                'args' => [
                    [
                        'name' => 'filter',
                        'type' => $types->getFilter(Marketplace::class), // Use automated filtering options
                    ],
                    [
                        'name' => 'sorting',
                        'type' => $types->getSorting(Marketplace::class), // Use automated sorting options
                    ],
                ],
                'resolve' => function ($root, $args) use ($types) {
                    $queryBuilder = $types->createFilteredQueryBuilder(Marketplace::class, $args['filter'] ?? [], $args['sorting'] ?? []);
                    $result = $queryBuilder->getQuery()->getArrayResult();
                    return $result;
                },
            ],
        ],
        'resolveField' => function($val, $args, $context, ResolveInfo $info) {
            return $this->{$info->fieldName}($val, $args, $context, $info);
        }
    ]);

    $schema = new Schema([
        'query' => $queryType,
    ]);

    $schema->assertValid();

    $server = new StandardServer([
        'schema' => $schema
    ]);

    $server->handleRequest();
} catch (\Exception $e) {
    StandardServer::send500Error($e);
}

Markerplace model

/**
 * @ORM\Entity()
 * @ORM\Table(name="marketplace")
 */
class Marketplace
{
    #use DomainAwareTrait;
    /**
     * @var int
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     * @ORM\Column(type="integer", options={"unsigned":true})
     */
    private $id;

    /**
     * @var string
     * @ORM\Column(type="string", length=14, unique=true, options={"unsigned":true})
     */
    private $code;

    /**
     * @var string
     * @ORM\Column(type="string", nullable=true, length=255)
     */
    private $name;

    /**
     * @return string
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @param string $id
     * @return Marketplace
     */
    public function setId($id): Marketplace
    {
        $this->id = $id;

        return $this;
    }

    /**
     * @return string
     */
    public function getCode(): string
    {
        return $this->code;
    }

    /**
     * @param string $code
     * @return Marketplace
     */
    public function setCode(string $code): Marketplace
    {
        $this->code = $code;

        return $this;
    }

    /**
     * @return string
     */
    public function getName(): string
    {
        return $this->name;
    }

    /**
     * @param string $name
     * @return Marketplace
     */
    public function setName(string $name): Marketplace
    {
        $this->name = $name;

        return $this;
    }
}

from graphql-doctrine.

PowerKiKi avatar PowerKiKi commented on June 3, 2024

I see that Marketplace has no relation at all with any other entities. This means that there is nothing to be used as a join filter in MarketplaceFilterGroupJoin. So MarketplaceFilterGroupJoin is effectively empty, but it is invalid to have an "empty" GraphQL type.

Somehow this never happened in our projects, but it clearly is something that should be supported and can be considered a bug. I'll see what I can do...

from graphql-doctrine.

PowerKiKi avatar PowerKiKi commented on June 3, 2024

Please try 65bf449 and let me know if it's fixed

from graphql-doctrine.

popovserhii avatar popovserhii commented on June 3, 2024

Yes, these changes have fixed my problem. Thanks :).
When do you plan to release these changes?

from graphql-doctrine.

PowerKiKi avatar PowerKiKi commented on June 3, 2024

Released as 5.0.1

from graphql-doctrine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.