-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
customTypeMapping, generateExtensionFieldsResolvers and Extension Fields produce invalid parameter names #964
Comments
This commit shows the broken broken test case. I believe the fix is in com.kobylynskyi.graphql.codegen.mapper.FieldDefinitionsToResolverDataModelMapper#getOperationParameters: // 1. First parameter is the parent object for which we are resolving fields (unless it's the root Query)
if (!Utils.isGraphqlOperation(parentTypeName)) {
String parentObjectParamType = graphQLTypeMapper
.getLanguageType(mappingContext, new TypeName(parentTypeName));
String parentObjectParamName = dataModelMapper
// The below is where the parameter type name is generated
// * parentObjectParamType = "com.example.Something"
// * parentTypeName = "Something"
// .capitalizeIfRestricted(mappingContext, Utils.unCapitalize(parentObjectParamType));
.capitalizeIfRestricted(mappingContext, Utils.unCapitalize(parentTypeName));
ParameterDefinition parameterDefinition = new ParameterDefinition();
parameterDefinition.setType(parentObjectParamType);
parameterDefinition.setName(parentObjectParamName);
parameterDefinition.setOriginalName(parentObjectParamName);
parameterDefinition.setDeprecated(DeprecatedDefinitionBuilder.build(mappingContext, resolvedField));
parameters.add(parameterDefinition);
} parentObjectParamType is the fully qualified, mapped type. Couple of options:
|
Exactly, It seems that all langs have the same problem. This seems feasible.
|
@martinlau thanks a lot for the detailed explanation and the proposed fix. |
Will be released as part of version 5.4.1 #980 |
Issue Description
When using customTypeMapping and generateExtensionFieldsResolvers to reference objects defined outside of the GraphQL Schema, for example:
Combined with extension fields on existing types:
Resolver classes are generated with parameter names based on the mapped value, rather than the original (non-qualified) value:
(Kotlin above - same issue arises with Java)
Steps to Reproduce
Refer to https://github.com/martinlau/graphql-codegen
Expected Result
Resolvers should be generated with a name based on the original type, rather than the fully qualified mapped type
Actual Result
Resolvers are generated with a name based on the fully qualified mapped type.
See https://github.com/martinlau/graphql-codegen/blob/main/target/generated-sources/graphql/com/github/martinlau/graphql/resolver/ExternalResolver.kt for the full example
Your Environment and Setup
And
The text was updated successfully, but these errors were encountered: