| Q | A
| ---------------- | -----
| Bug report? | yes
| Feature request? | no
| BC Break report? | yes
| RFC? | no
| Version/Branch | 0.12.0, 0.12.1
Defining multiple schemas in v0.12.x prevents "nested resolvers" from being called and the query fails with Cannot return null for non-nullable field AdminQueries.someField.
It works again if the profile schema is commented-out.
In v0.11, this works fine.
Query:
{
admin(token: "foo") {
someField
}
}
Types:
type AdminQueryRoot {
admin(token: String!): AdminQueries!
}
type AdminQueries {
someField: String!
}
type ProfileQueryRoot {
dummy: String
}
Config:
overblog_graphql:
definitions:
mappings:
auto_discover: false
types:
-
type: graphql
dir: '%kernel.project_dir%/config/graphql'
suffix: ''
schema:
admin:
query: AdminQueryRoot
resolver_maps:
- app.admin_resolver_map
profile:
query: ProfileQueryRoot
resolver_maps:
- app.profile_resolver_map
Resolvers:
use Overblog\GraphQLBundle\Resolver\ResolverMap;
class AdminResolverMap extends ResolverMap
{
private $fieldResolverInvoker;
public function __construct(callable $fieldResolverInvoker)
{
$this->fieldResolverInvoker = $fieldResolverInvoker;
}
protected function map()
{
return [
'AdminQueryRoot' => [static::RESOLVE_FIELD => $this->fieldResolverInvoker],
'AdminQueries' => [static::RESOLVE_FIELD => $this->fieldResolverInvoker],
];
}
}
class ProfileResolverMap extends ResolverMap
{
private $fieldResolverInvoker;
public function __construct(callable $fieldResolverInvoker)
{
$this->fieldResolverInvoker = $fieldResolverInvoker;
}
protected function map()
{
return [
'ProfileQueryRoot' => [static::RESOLVE_FIELD => $this->fieldResolverInvoker],
];
}
}
$fieldResolverInvoker is a class with __invoke that calls another service based on ResolveInfo, but that's not important.
@fantomas662 this seem to be more an issue due to a change in graphql-php lib can you provide both version of webonyx/graphql-php (before and now) please?
It works with:
overblog/graphql-bundle v0.11.14 This bundle provides tools to build a GraphQL server in your Symfony App.
webonyx/graphql-php v0.13.6 A PHP port of GraphQL reference implementation
But doesn't work with:
overblog/graphql-bundle v0.12.1 This bundle provides tools to build a GraphQL server in your Symfony App.
webonyx/graphql-php v0.13.6 A PHP port of GraphQL reference implementation
0.12.0 and master didn't work either.
Test don't fails for me, I could not validate Windows since we have some making work right now. Are you using Windows? Does the test covers your issue? If this is the case I'll need some more information to can fix this.
I'm on OS X.
I've created a demo app for this bug, see https://github.com/fantomas662/graphql-bug-repr
If you go to http://localhost/graphiql/admin and try to run the following query, it will fail with Cannot return null for non-nullable field AdminQueries.example..
{
admin(token: "foo_bar") {
example
}
}
If you comment out the profile schema in config/packages/graphql.yaml, then you get the expected response:
{
"data": {
"admin": {
"example": "This is an example. Your token is: foo_bar"
}
}
}
If you downgrade to v0.11 (and uncomment auto_mapping: false in config/packages/graphql.yaml), then it works even with the profile schema.
Thank you @fantomas662 for demo app, I can reproduce the issue, I'm now looking for the best fix.
here is the new version v0.12.2 with the fix. Thank you for the report :+1: