thecodingmachine / graphqlite

Use PHP Attributes/Annotations to declare your GraphQL API
https://graphqlite.thecodingmachine.io
MIT License
554 stars 95 forks source link

Add support of types from vendor packages #657

Closed fogrye closed 4 months ago

fogrye commented 5 months ago

This is mainly for input types but could be considered for output also.

While you can use classes from various libraries you are limited to only current project folders in case you moved some input types to external package. In my case I have some where/sort classes + logic moved as shared library and want to have them used as types, I have added all attributes but SchemaFactory will ignore them as GlobClassExplorer only looks into project src.

I'm happily contribute to this one + https://github.com/thecodingmachine/class-explorer but that is a big change for class explorer and maintainers of that lib may not be happy about it.

I hope my request to support vendor packages types will find supporters as IMHO it's must have for complex projects.

Happily receive any feedback on this, thx.

oojacoboo commented 5 months ago

@fogrye Can you not just include the namespace for these classes in the SchemaFactory configuration?

SchemaFactory:: addTypeNamespace('Vendor\\Namespace');
fogrye commented 5 months ago

@oojacoboo I wish so, but as readme in class explorer says - it just goes through project files but not also vendor files. Thats why I want to suggest this feature here and in class-explorer project.

oojacoboo commented 5 months ago

@fogrye I think it's reasonable to assume types might exist as vendor files and I agree that's something that should be optionally supported. That said, I'm assuming there are some performance considerations - that needs to be taken into account somehow.

I'm not a maintainer for class-explorer, but I'm assuming we could get a PR merged there if it's not breaking and there aren't any performance implications, or performance implications are optional based on vendor access needs.

fogrye commented 4 months ago

@oojacoboo so seems to me that class-explorer is kinda dead, I found that @moufmouf was working on something what I actually need here but haven't finished his work. What do you think if I will finish that and we change dependency for this project to my fork?

oojacoboo commented 4 months ago

I'm wondering if there might be a better lib for handling all of this? Have you looked? Swapping out that lib might be a better option in the long term.

fogrye commented 4 months ago

@oojacoboo I found a couple but not that good:

I'm personally more for 1st option, what do you think?

oojacoboo commented 4 months ago

@fogrye @oprypkhantc suggested looking at https://github.com/alekitto/class-finder/ as well. Looks like it supports Composer, which would be PSR0/4, etc.

fogrye commented 4 months ago

@oojacoboo so could you pls check the PR, I believe we can have it merged

oojacoboo commented 4 months ago

Thanks again - merged.