Skip to content

Add @GraphQlType Annotation #1089

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

Closed
wants to merge 1 commit into from

Conversation

Plygon
Copy link

@Plygon Plygon commented Nov 19, 2024

A Java class name might not perfectly correspond to the corresponding GraphQL type name. In such cases, the default ClassNameTypeResolver cannot determine the GraphQL type.

This change introduces an annotation, @GraphQlType, which allows you to override the name picked up by the default classNameExtractor in ClassNameTypeResolver.

@pivotal-cla
Copy link

@Plygon Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 19, 2024
@Plygon Plygon closed this Nov 20, 2024
@Plygon Plygon deleted the graphql-type-annotation branch November 20, 2024 19:40
@bclozel
Copy link
Member

bclozel commented Nov 21, 2024

We didn't have time to discuss your contribution @Plygon - I guess you closed this because of the CLA?
Even if we don't integrate this @GraphQlType annotation, is there something we can do to make this easier on your side maybe?

@bclozel bclozel added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 21, 2024
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Nov 21, 2024

If there is a common classname convention, you can set a classNameExtractor function on ClassNameTypeResolver to deal with that. The same can also look at an annotation like the one proposed here, so it should be relatively straight forward to achieve this. For us it would be less ideal to introduce such an annotation in the framework if its only purpose to customize the name of union member or interface implementation types.

@Plygon
Copy link
Author

Plygon commented Nov 21, 2024

Thanks @bclozel and @rstoyanchev. I closed the PR because I need to make sure I am following my company's policies before signing the CLA. Waiting to hear back from them.

I am overriding the classNameExtractor already, but this seemed like it could be a good out-of-the-box feature. In my eyes, it is much more direct and convenient to be able to specify the GaphQL interface/union type on the data class itself, rather than adding each interface type resolver in the config file. But I also see that this is a bit of an edge-case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants