GraphQL interfaces should still be annotated when using the `@annotate` directive
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 217
- Forks
- 116
- PR merge metrics
- No merged PRs in 30d
Description
Given an interface and a type, both of which have the @annotate directive placed on them, annotations are only generated for the GraphQL type.
For example (you can also find it as a cloneable repo):
interface TestInterface @annotate(name: "com.example.badinterfacegeneration.TestAnnotation") {
name: String! @annotate(name: "com.example.badinterfacegeneration.TestAnnotation", target: "get")
}
type TestType @annotate(name: "com.example.badinterfacegeneration.TestAnnotation") {
name: String! @annotate(name: "com.example.badinterfacegeneration.TestAnnotation", target: "get")
}
generates the following class:
@TestAnnotation
public class TestType {
private String name;
public TestType() {
}
public TestType(String name) {
this.name = name;
}
@TestAnnotation
public String getName() {
return name;
}
// ... the rest of the generated code
}
and interface:
public interface TestInterface {
String getName();
void setName(String name);
}
The Interface does not have any annotations despite having them defined in the GraphQL schema. This is not the behaviour I expect. There should either be an error that indicates that annotations cannot be placed on interfaces or annotations should be placed on the generated interface.
I don't know how feasible this feature is to implement. If it is not possible, an addition to the documentation or a warning during generation would be nice.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the GraphQL schema example and the @annotate directive handling for generated interfaces, then inspect the existing generation tests if available. Add a regression case covering annotations on an interface and establish whether generation should apply them or report the unsupported usage; done means the behavior is covered and matches the chosen outcome.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, java, kotlin
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100