thecodingmachine / graphqlite

Use PHP Attributes/Annotations to declare your GraphQL API

Home Page:https://graphqlite.thecodingmachine.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support of types from vendor packages

fogrye opened this issue · comments

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.

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

SchemaFactory:: addTypeNamespace('Vendor\\Namespace');

@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.

@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.

@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?

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.

@oojacoboo I found a couple but not that good:

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

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

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

Thanks again - merged.