| Q | A
| ---------------- | -----
| Bug report? | no
| Feature request? | no
| BC Break report? | no
| RFC? | no
overblog/graphql-bundle v0.10.3
overblog/graphql-php-generator v0.6.0
webonyx/graphql-php v0.11.6
I have an issue where Executor complains that a non-nullable field is null when the object to return is from an implementation of an Interface and the property is from another implementation.
- Cannot return null for non-nullable field File.versions.
* vendor/webonyx/graphql-php/src/Executor/Executor.php:923
The object to return is from the class Folder, a sibling of File.
My (simplified) definitions are as follow:
Path:
type: interface
config:
fields:
id:
type: 'ID!'
name:
type: 'String!'
File:
type: object
config:
fields:
id:
type: 'ID!'
name:
type: 'String!'
versions:
type: '[Version]!'
interfaces:
- Path
Folder:
type: object
config:
fields:
id:
type: 'ID!'
name:
type: 'String!'
interfaces:
- Path
The query is:
tree {
items {
id
name
... on File {
versions{
fullName
downloadLink
}
}
}
}
The php classes Folder.php and File.php extend the class Path.php. Only File.php has a property $versions. The value version is only requested for the type File. But the Executor refuses to return a Folder object.
I "fixed" the issue by moving $versions to Path.php, but I don't understand what I'm doing wrong. If a property is defined for a type, why should it also be defined for all "siblings" of that type?
Hi does your resolver correctly returns version, also what about resolveType config on Path type?
(Sorry for late reply I was a way busy last few days.)
Hi @Alsciende , maybe this POC can help you : https://github.com/Samffy/graphql-poc
It use a simple model, but implement interface.
@mcg-web, do not hesitate to criticize this work if you notice some issues.
hi @Samffy can we reference this poc in documentation, it look really nice and will be a good start for many users I think.
@mcg-web, of course, I hope this poc can help some people start with your awesome bundle 馃憤
Thank you @Samffy , I added your repo to REAME:+1:
Most helpful comment
Hi @Alsciende , maybe this POC can help you : https://github.com/Samffy/graphql-poc
It use a simple model, but implement interface.
@mcg-web, do not hesitate to criticize this work if you notice some issues.