Skip to content

Commit 32d1065

Browse files
committed
fix failed tests
1 parent 72f74ce commit 32d1065

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/__snapshots__/code-generator.test.ts.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import type { Maybe, Book, Author } from './types';
1212
1313
export * from '@mizdra/graphql-codegen-typescript-fabbrica/helper';
1414
export type OptionalBook = {
15-
id: string;
16-
title: string;
17-
author: OptionalAuthor;
15+
id?: string | undefined;
16+
title?: string | undefined;
17+
author?: OptionalAuthor | undefined;
1818
};
1919
2020
const BookFieldNames = ['id', 'title', 'author'] as const;
@@ -57,9 +57,9 @@ export function defineBookFactory<
5757
}
5858
5959
export type OptionalAuthor = {
60-
id: string;
61-
name: string;
62-
books: Book[];
60+
id?: string | undefined;
61+
name?: string | undefined;
62+
books?: Book[] | undefined;
6363
};
6464
6565
const AuthorFieldNames = ['id', 'name', 'books'] as const;

src/code-generator.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ describe('generateOptionalTypeDefinitionCode', () => {
1010
const typeInfo: TypeInfo = {
1111
name: 'Book',
1212
fields: [
13-
{ name: 'id', typeString: 'string' },
14-
{ name: 'title', typeString: 'string', comment: transformComment('The book title') },
13+
{ name: 'id', typeString: 'string | undefined' },
14+
{ name: 'title', typeString: 'string | undefined', comment: transformComment('The book title') },
1515
],
1616
comment: transformComment('The book'),
1717
};
1818
const actual = generateOptionalTypeDefinitionCode(typeInfo);
1919
expect(actual).toMatchInlineSnapshot(`
2020
"/** The book */
2121
export type OptionalBook = {
22-
id: string;
22+
id?: string | undefined;
2323
/** The book title */
24-
title: string;
24+
title?: string | undefined;
2525
};
2626
"
2727
`);
@@ -38,17 +38,17 @@ describe('generateCode', () => {
3838
{
3939
name: 'Book',
4040
fields: [
41-
{ name: 'id', typeString: 'string' },
42-
{ name: 'title', typeString: 'string' },
43-
{ name: 'author', typeString: 'OptionalAuthor' },
41+
{ name: 'id', typeString: 'string | undefined' },
42+
{ name: 'title', typeString: 'string | undefined' },
43+
{ name: 'author', typeString: 'OptionalAuthor | undefined' },
4444
],
4545
},
4646
{
4747
name: 'Author',
4848
fields: [
49-
{ name: 'id', typeString: 'string' },
50-
{ name: 'name', typeString: 'string' },
51-
{ name: 'books', typeString: 'Book[]' },
49+
{ name: 'id', typeString: 'string | undefined' },
50+
{ name: 'name', typeString: 'string | undefined' },
51+
{ name: 'books', typeString: 'Book[] | undefined' },
5252
],
5353
},
5454
];

0 commit comments

Comments
 (0)