Skip to content

Commit

Permalink
Fix missing arguments when naming-convention resolves to same name as…
Browse files Browse the repository at this point in the history
… the original
  • Loading branch information
santino committed Sep 22, 2022
1 parent 853f515 commit 2f70663
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .changeset/brave-toys-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-mesh/transform-naming-convention': patch
---

Fix missing arguments when naming-convention resolves to same name as the original
42 changes: 20 additions & 22 deletions packages/transforms/naming-convention/src/bareNamingConvention.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,30 +130,28 @@ export default class NamingConventionTransform implements MeshTransform {
const useArgName = newArgName || argName;
const argIsInputObjectType = isInputObjectType(argConfig.type);

if (argName === newArgName && !argIsInputObjectType) {
return args;
if (argName !== useArgName) {
// take advantage of the loop to map arg name from Old to New
argsMap[useArgName] = !argIsInputObjectType
? argName
: {
[argName]: Object.keys((argConfig.type as GraphQLInputObjectType).toConfig().fields).reduce(
(inputFields, inputFieldName) => {
if (Number.isFinite(inputFieldName)) return inputFields;

const newInputFieldName = fieldNamingConventionFn(inputFieldName as string);
return newInputFieldName === inputFieldName
? inputFields
: {
...inputFields,
[fieldNamingConventionFn(inputFieldName as string)]: inputFieldName,
};
},
{}
),
};
}

// take advantage of the loop to map arg name from Old to New
argsMap[useArgName] = !argIsInputObjectType
? argName
: {
[argName]: Object.keys((argConfig.type as GraphQLInputObjectType).toConfig().fields).reduce(
(inputFields, inputFieldName) => {
if (Number.isFinite(inputFieldName)) return inputFields;

const newInputFieldName = fieldNamingConventionFn(inputFieldName as string);
return newInputFieldName === inputFieldName
? inputFields
: {
...inputFields,
[fieldNamingConventionFn(inputFieldName as string)]: inputFieldName,
};
},
{}
),
};

return {
...args,
[useArgName]: argConfig,
Expand Down

0 comments on commit 2f70663

Please sign in to comment.