Closed tigitz closed 1 year ago
@oojacoboo Here's an, hopefully, clearer explanation.
I took some time to think about a solution and I think it could be addressed by providing an additional way to define types.
graphqlite:
namespace:
types:
# Could be the default way to import types with a requirement of having this class covered by the autoload
- App\Model\Type
# For "non-autoload-covered" namespaces
- {namespace: 'Vendor\Package\Type', path:'../../vendor/package/'}
And build the classNameMapper this way:
// Take care of composer autoload namespace
$classNameMapper = ClassNameMapper::createFromComposerFile(null, null, true);
// Take care of non composer autoload namespace
$classNameMapper->registerPsr4Namespace($namespace, $path);
Although I'm not familiar with the internal, I'm wondering if what doctrine is doing can just be reused for graphqlite as this ORM config for example allows exactly what I'm trying to achieve with graphql mapping which is using mapping that don't necessarily belong to the "app" itself.
doctrine:
orm:
mappings:
Inventory:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/../vendor/Company/Package/Inventory/src'
prefix: 'Company\Inventory'
alias: Inventory
I know @moufmouf is quite busy these days but if he can chime in to provide his opinion quickly that would be awesome as it would remove the last barrier for my company to go all-in on graphqlite and support the development.
Why aren't you autoloading these classes like everything else? I'm really not familiar with the Symfony integration, but AFAIK, all of the autoloading is going to be handled by Composer. GraphQLite does register the type namespace though. I believe this is so it knows where to scan for annotations. I have no idea how that's defined in Symfony, but in GraphQLite, you'll use SchemaFactory::addTypeNamespace
This issue is stale because it has been open 6 month with no activity. You can reopen it if the issue is still happening.
Following https://github.com/thecodingmachine/graphqlite/issues/333
When you specify a namespace in
types
configuration:That is not covered by the namespace defined in the
autoload
attribute of the composer.json:It's not working.
After some investigation it's due to: https://github.com/thecodingmachine/graphqlite-bundle/blob/a14b9a0313e0bd788d33a08ca98fb2bc845fb371/DependencyInjection/GraphqliteCompilerPass.php#L478
Where
ClassNameMapper::createFromComposerFile
is used but it unfortunately only retrieves classes that are namespaced with namespaces declared in theautoload
attribute of the composer.json file