Skip to content

Commit c09f183

Browse files
yuthkaustavghosh06
authored andcommitted
fix(amplify-graphql-types-generator): add inflection black list
Added a black list to prevent singularization of `delta` -> `deltum` fixes #1328
1 parent 8d8e522 commit c09f183

File tree

1 file changed

+26
-9
lines changed
  • packages/amplify-graphql-types-generator/src/swift

1 file changed

+26
-9
lines changed

packages/amplify-graphql-types-generator/src/swift/helpers.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,24 @@ const builtInScalarMap = {
3535
[GraphQLID.name]: 'GraphQLID'
3636
};
3737

38+
const INFLECTOR_BLACK_LIST = ['delta'];
39+
40+
Inflector.inflections('en', function(inflect: any) {
41+
INFLECTOR_BLACK_LIST.forEach(w => {
42+
inflect.uncountable(w, w);
43+
});
44+
});
45+
3846
export class Helpers {
3947
constructor(public options: CompilerOptions) {}
4048

4149
// Types
4250

43-
typeNameFromGraphQLType(type: GraphQLType, unmodifiedTypeName?: string, isOptional?: boolean): string {
51+
typeNameFromGraphQLType(
52+
type: GraphQLType,
53+
unmodifiedTypeName?: string,
54+
isOptional?: boolean
55+
): string {
4456
if (isNonNullType(type)) {
4557
return this.typeNameFromGraphQLType(type.ofType, unmodifiedTypeName, false);
4658
} else if (isOptional === undefined) {
@@ -64,7 +76,9 @@ export class Helpers {
6476
builtInScalarMap[type.name] ||
6577
(this.options.passthroughCustomScalars
6678
? this.options.customScalarsPrefix + type.name
67-
: getTypeForAWSScalar(type) ? getTypeForAWSScalar(type): GraphQLString.name)
79+
: getTypeForAWSScalar(type)
80+
? getTypeForAWSScalar(type)
81+
: GraphQLString.name)
6882
);
6983
}
7084

@@ -167,13 +181,16 @@ export class Helpers {
167181
}
168182

169183
propertyFromInputField(field: GraphQLInputField) {
170-
return Object.assign({}, {
171-
propertyName: camelCase(field.name),
172-
typeName: this.typeNameFromGraphQLType(field.type),
173-
isOptional: !(field.type instanceof GraphQLNonNull),
174-
description: field.description || null,
175-
name: field.name,
176-
});
184+
return Object.assign(
185+
{},
186+
{
187+
propertyName: camelCase(field.name),
188+
typeName: this.typeNameFromGraphQLType(field.type),
189+
isOptional: !(field.type instanceof GraphQLNonNull),
190+
description: field.description || null,
191+
name: field.name
192+
}
193+
);
177194
}
178195

179196
propertiesForSelectionSet(

0 commit comments

Comments
 (0)