Comments (6)
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.
@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.
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.
Please try 65bf449 and let me know if it's fixed
from graphql-doctrine.
Yes, these changes have fixed my problem. Thanks :).
When do you plan to release these changes?
from graphql-doctrine.
Released as 5.0.1
from graphql-doctrine.
Related Issues (20)
- Support collection in setter HOT 4
- Event driven programming HOT 2
- phpstan HOT 1
- Documentation generation error HOT 3
- Some usage issues HOT 3
- Custom Trait in Model throws Exception HOT 5
- Cannot return null for non-nullable field HOT 5
- More sorting orders HOT 3
- Groups with OR logic and Joins HOT 2
- Support Embeddable classes HOT 2
- $types->getInput() doesn't work as expected HOT 1
- Hello, could you give me a demo? HOT 1
- No type registered with key `date`. Either correct the usage, or register it in your custom types container when instantiating `GraphQL\Doctrine\Types` HOT 13
- Getting entity fields with magic methods HOT 3
- Support webonyx/graphql-php 14 HOT 1
- Properties starting with is/has IE: isActive instead of getActive HOT 1
- Detached Entity HOT 2
- Problem when using with "doctrine/doctrine-bundle" HOT 7
- Slim Framework Example HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-doctrine.