-
-
Notifications
You must be signed in to change notification settings - Fork 840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cannot perform GraphQL sub-selections on non-doctrine resource collections #6365
Comments
Can I see the UserProvider? Not sure if/how graphql works without doctrine, maybe that you need a custom resolver. |
@soyuka Currently the UserProvider is quite empty, just returning a mock object. |
I see, inspect your schema, IIRC the type is computed at core/src/GraphQl/Type/FieldsBuilder.php Lines 215 to 228 in e867d07
User[] can't be found, is it a resource?
|
Yes it has the |
With your comment pointing out the #[ApiProperty(
builtinTypes: [new Type(
builtinType: Type::BUILTIN_TYPE_ARRAY,
collection: true,
collectionKeyType: new Type(builtinType: Type::BUILTIN_TYPE_INT),
collectionValueType: new Type(builtinType: Type::BUILTIN_TYPE_OBJECT, class: User::class),
)],
)] Is that a valid use of |
you shouldn't need this, try installing this:
as suggested: https://github.com/api-platform/core/blob/main/composer.json#L121 |
Ok so without using the composer.json {
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=8.3",
"ext-ctype": "*",
"ext-iconv": "*",
"api-platform/core": "^3.2",
"doctrine/dbal": "^3",
"doctrine/doctrine-bundle": "^2.12",
"doctrine/doctrine-migrations-bundle": "^3.3",
"doctrine/orm": "^3.1",
"phpstan/phpdoc-parser": "^1.29",
"symfony/asset": "7.0.*",
"symfony/console": "*",
"symfony/dotenv": "*",
"symfony/flex": "^2",
"symfony/framework-bundle": "*",
"symfony/runtime": "*",
"symfony/twig-bundle": "7.0.*",
"symfony/yaml": "*",
"webonyx/graphql-php": "^15.11"
},
"config": {
"allow-plugins": {
"php-http/discovery": true,
"symfony/flex": true,
"symfony/runtime": true
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "7.0.*"
}
},
"require-dev": {
"phpmd/phpmd": "^2.15.0",
"phpstan/phpstan": "^1.10.67",
"phpstan/phpstan-doctrine": "^1.3",
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/phpstan-symfony": "^1.3",
"phpunit/phpunit": "^10.2",
"squizlabs/php_codesniffer": "*",
"symfony/maker-bundle": "^1.58"
}
}
|
I assume you cleared the cache to reload the metadata after adding the phpdoc-parser? |
|
could not reproduce |
I somehow can not join the slack workspace, so I'm asking here. Also it might be a bug but I'm not sure, so please feel free to let me know where is the better place for this topic.
I am trying to perform a sub-selection query on an array/collection resource, but my resources are not doctrine entities.
If I add all doctrine annotations (just for trying), then the sub-selection works without any other changes.
Here is the code example which fails:
And the User class:
Here is an example of query:
And variables:
There is no issue with the meta sub-selection, but with the users it gives the following error:
"Field \"users\" of type \"Iterable!\" must not have a sub selection.",
As I said above, if I add all ORM annotation to convert these simple classes into entities, then the sub-selection works out of the box, with the same code and same query.
Am I missing something to tell graphql/apiplatform that
$users
is an array of theUser::class
resource?Thank you already for your support
The text was updated successfully, but these errors were encountered: