-
-
Notifications
You must be signed in to change notification settings - Fork 114
Description
Issue Description
I would like to generate a type as an interface that has parameterized fields, without using separate field resolvers for the parameterized fields. Since the type is being generated as an interface rather than a concrete class, I would expect the getter methods for the parameterized fields to be properly parameterized. However, there are no such parameters on the getters for the parameterized fields, and the generated interface is invalid/unusable.
Steps to Reproduce
Excerpt of relevant graphql schema:
"used with typesAsInterfaces config"
directive @asInterface on OBJECT
"used with fieldsWithResolvers config"
directive @noResolver on FIELD_DEFINITION
type Foo @asInterface {
simpleField: String!
parameterizedField(count: Int!): String! @noResolver
}
Expected Result
Expected generated interface:
public interface Foo {
@javax.validation.constraints.NotNull
String getSimpleField();
@javax.validation.constraints.NotNull
String getParameterizedField(int count);
}
Actual Result
Generated interface:
public interface Foo {
@javax.validation.constraints.NotNull
String getSimpleField();
// missing parameter here
@javax.validation.constraints.NotNull
String getParameterizedField();
}
This interface is unusable/broken. In addition to being unable to implement the method in terms of its parameters, this is not even valid for graphql kickstart:
Failed to instantiate [graphql.kickstart.tools.SchemaParser]: Factory method 'schemaParser' threw exception; nested exception is graphql.kickstart.tools.resolver.FieldResolverError: No method found as defined in schema :216 with any of the following signatures (with or without one of [interface graphql.schema.DataFetchingEnvironment] as the last argument), in priority order:
com.workforcesoftware.timesheetservice.generated.graphql.model.Foo.parameterizedField(~count)
com.workforcesoftware.timesheetservice.generated.graphql.model.Foo.getParameterizedField(~count)
Your Environment and Setup
- graphql-java-codegen version: 5.2.0
- Build tool: Gradle
- Config:
Excerpt ofgraphqlCodegenfrom build.gradle
generateApis = true
apiInterfaceStrategy = "INTERFACE_PER_OPERATION"
apiRootInterfaceStrategy = "DO_NOT_GENERATE"
apiReturnType = "graphql.execution.DataFetcherResult"
generateDataFetchingEnvironmentArgumentInApis = true
generateImmutableModels = true
generateParameterizedFieldsResolvers = true
fieldsWithResolvers = ["@customResolver"]
fieldsWithoutResolvers = ["@noResolver"]
typesAsInterfaces = ["@asInterface"]