Skip to content

Commit a278245

Browse files
sebvilhelmardeois
andauthored
fix: don't recase __typename (#64)
Co-authored-by: Corentin Ardeois <[email protected]>
1 parent b0eb60a commit a278245

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ const getMockString = (
228228
const typenameConverter = createNameConverter(typenamesConvention, transformUnderscore);
229229
const casedName = typenameConverter(typeName);
230230
const casedNameWithPrefix = typenameConverter(typeName, typesPrefix);
231-
const typename = addTypename ? `\n __typename: '${casedName}',` : '';
232-
const typenameReturnType = addTypename ? `{ __typename: '${casedName}' } & ` : '';
231+
const typename = addTypename ? `\n __typename: '${typeName}',` : '';
232+
const typenameReturnType = addTypename ? `{ __typename: '${typeName}' } & ` : '';
233233

234234
if (terminateCircularRelationships) {
235235
return `

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,23 +1463,23 @@ export const aWithAvatar = (overrides?: Partial<WithAvatar>): { __typename: 'Wit
14631463
};
14641464
};
14651465

1466-
export const aCamelCaseThing = (overrides?: Partial<CamelCaseThing>): { __typename: 'CamelCaseThing' } & CamelCaseThing => {
1466+
export const aCamelCaseThing = (overrides?: Partial<CamelCaseThing>): { __typename: 'camelCaseThing' } & CamelCaseThing => {
14671467
return {
1468-
__typename: 'CamelCaseThing',
1468+
__typename: 'camelCaseThing',
14691469
id: overrides && overrides.hasOwnProperty('id') ? overrides.id! : '345b9cf9-00fa-4974-800f-aeee5ee7fd42',
14701470
};
14711471
};
14721472

1473-
export const aPrefixedResponse = (overrides?: Partial<PrefixedResponse>): { __typename: 'PrefixedResponse' } & PrefixedResponse => {
1473+
export const aPrefixedResponse = (overrides?: Partial<PrefixedResponse>): { __typename: 'Prefixed_Response' } & PrefixedResponse => {
14741474
return {
1475-
__typename: 'PrefixedResponse',
1475+
__typename: 'Prefixed_Response',
14761476
ping: overrides && overrides.hasOwnProperty('ping') ? overrides.ping! : 'sunt',
14771477
};
14781478
};
14791479

1480-
export const anAbcType = (overrides?: Partial<AbcType>): { __typename: 'AbcType' } & AbcType => {
1480+
export const anAbcType = (overrides?: Partial<AbcType>): { __typename: 'ABCType' } & AbcType => {
14811481
return {
1482-
__typename: 'AbcType',
1482+
__typename: 'ABCType',
14831483
abc: overrides && overrides.hasOwnProperty('abc') ? overrides.abc! : 'sit',
14841484
};
14851485
};

0 commit comments

Comments
 (0)