-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GraphQLite is automatically making interface implementations when it shouldn't #423
Comments
@MattBred I've noticed the same thing. It's a bit harmless, as the interface isn't used, just generated in the schema. But, it is sloppy and confusing. A PR on this would be awesome :) |
As you can see here: graphqlite/src/Mappers/RecursiveTypeMapper.php Lines 212 to 223 in 3b97f9d
Your type somehow is not yet part of the typeRegistry, might be a ordering issue in the recursive type mapper? |
It's probably related to the mapping cache in the |
You are right, this seems quite naive. The interface type name is generated in this function called on line 214 above: graphqlite/src/NamingStrategy.php Lines 31 to 34 in 3b97f9d
It should actually check if there is a class in php implementing this interface. At least thats what the docs suggest it does but apparently not. |
There are two mappings as well, the actual FQCN and the GQL name. I don't find that these two mappings work well with each other either. IMO, we'd benefit from having a single mapping cache that's more robust. |
@oojacoboo what do you mean by two mappings? |
The RecursiveTypeMapper has:
I found it frustrating to work with all of these different maps and think this responsibility would probably be better left to a mapping abstraction. |
I have ran into the same issue, this causes issues when generating types from schema, i have to handle the interface type even though i already know it would be one of N types |
A PR on this is certainly welcomed! |
My guess is the code that is commented out here is what is supposed to be skipping this creation if a class implementing that interface exists?
|
Version: 5.0.1
According to https://graphqlite.thecodingmachine.io/docs/inheritance-interfaces, GraphQLite should only make an
Impl
type when it can't find another type that implements that interface:However, it does it no matter what on my end:
This generates the following schema:
The text was updated successfully, but these errors were encountered: