Skip to content

Commit 2332ad1

Browse files
BenStirrupardeois
andauthored
fix: wrong type generated when terminateCircularRelationships is true (#70)
For example : a type like VirtualBan would be wrongly written as VirtualIBAN Co-authored-by: Corentin Ardeois <[email protected]>
1 parent 896fbc9 commit 2332ad1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ const getNamedType = (opts: Options<NamedTypeNode>): string | number | boolean =
181181
}
182182
}
183183
if (opts.terminateCircularRelationships) {
184-
return `relationshipsToOmit.has('${name}') ? {} as ${name} : ${toMockName(
184+
return `relationshipsToOmit.has('${casedName}') ? {} as ${casedName} : ${toMockName(
185185
name,
186186
casedName,
187187
opts.prefix,

tests/__snapshots__/typescript-mock-data.spec.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,7 @@ export const aUser = (overrides?: Partial<User>, relationshipsToOmit: Set<string
19541954
status: overrides && overrides.hasOwnProperty('status') ? overrides.status! : Status.Online,
19551955
customStatus: overrides && overrides.hasOwnProperty('customStatus') ? overrides.customStatus! : AbcStatus.HasXyzStatus,
19561956
scalarValue: overrides && overrides.hasOwnProperty('scalarValue') ? overrides.scalarValue! : 'neque',
1957-
camelCaseThing: overrides && overrides.hasOwnProperty('camelCaseThing') ? overrides.camelCaseThing! : relationshipsToOmit.has('camelCaseThing') ? {} as camelCaseThing : aCamelCaseThing({}, relationshipsToOmit),
1957+
camelCaseThing: overrides && overrides.hasOwnProperty('camelCaseThing') ? overrides.camelCaseThing! : relationshipsToOmit.has('CamelCaseThing') ? {} as CamelCaseThing : aCamelCaseThing({}, relationshipsToOmit),
19581958
unionThing: overrides && overrides.hasOwnProperty('unionThing') ? overrides.unionThing! : relationshipsToOmit.has('Avatar') ? {} as Avatar : anAvatar({}, relationshipsToOmit),
19591959
};
19601960
};
@@ -2008,7 +2008,7 @@ export const aQuery = (overrides?: Partial<Query>, relationshipsToOmit: Set<stri
20082008
relationshipsToOmit.add('Query');
20092009
return {
20102010
user: overrides && overrides.hasOwnProperty('user') ? overrides.user! : relationshipsToOmit.has('User') ? {} as User : aUser({}, relationshipsToOmit),
2011-
prefixed_query: overrides && overrides.hasOwnProperty('prefixed_query') ? overrides.prefixed_query! : relationshipsToOmit.has('Prefixed_Response') ? {} as Prefixed_Response : aPrefixedResponse({}, relationshipsToOmit),
2011+
prefixed_query: overrides && overrides.hasOwnProperty('prefixed_query') ? overrides.prefixed_query! : relationshipsToOmit.has('PrefixedResponse') ? {} as PrefixedResponse : aPrefixedResponse({}, relationshipsToOmit),
20122012
};
20132013
};
20142014
"

0 commit comments

Comments
 (0)