-
-
Notifications
You must be signed in to change notification settings - Fork 248
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
Consider using the containing objects name as a prefix for schema types #1416
Comments
There is a simpler way which is using the Using the parent namespace is probably not desirable in the most cases and we can't really do it in a smart way because each Schema is independent from each other. The annotation lets you control the name easily. |
Indeed, I think the option to use This could be eliminated by having a second set of types that we translate back and forth from / to the domain types, however there is no Chimney for Scala 3 to alleviate the maintenance of these types and it seems there might never be since the macros in Scala 3 are not compatible with Chimney's code base. Because of this we looked into an easier way to do the renaming ad-hoc and with less boilerplate. Thank you for your response, at the moment this is not a real problem for us, so you can just close the issue if you want to, but I think it might provide a good guidance for other people trying to accomplish similar things. |
I think it's difficult to find a heuristic that satisfies everyone but there might be ways to reduce the boilerplate so I'll keep this open and give it some thoughts 👍 |
That's your root problem here. You are using domain-types for your graphql schema. |
Unfortunately our project uses Scala 3 and there is no Chimney or other library to my knowledge that can make it easier to generate such DTOs without having to make them by hand. Making them by hand will quickly double the size of the project, which is just not feasible at the moment. Avoiding naming collisions as described in the first post is something that can be achieved no matter if you use dedicated DTOs or not - it just brings convenience. |
@lachezar have a look at https://github.com/arainko/ducktape |
I am running into naming collisions and I have to rename things (make them unique) otherwise the schema generation fails.
Example:
If you use the following validation types as part of your schema, then there will be collision since
InvalidAge
occurs twice. You can resolve this by either prefixing the name of the case classes with their wrapping object's name or by manually generating the schema and renaming itSchema.gen.rename("PersonErrorInvalidAge")
.However, I believe it will be better experience if it is possible to just use the enwrapping object as a namespace / prefix and produce unique type names for the schema automatically.
I am not sure if this is possible / easy or that it wont break anything else, but I find it as a great feature that will make things simpler when developing with Caliban.
The text was updated successfully, but these errors were encountered: