Skip to content

Commit e9b7893

Browse files
committed
[typescript-operations] Generate Exact into target file (#10504)
* Create standalone test * Add Exact and set up test * Remove Exact from typescript plugin * Update tests that switch out Exact * Update dev tests * Add changeset * Update test * Add InputMaybe Scalars tests * Fix schema in test * Fix up examples tests * Add result enum example
1 parent 73fa11b commit e9b7893

65 files changed

Lines changed: 202 additions & 97 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/lovely-sloths-kiss.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@graphql-codegen/typescript-operations': major
3+
'@graphql-codegen/typescript': major
4+
'@graphql-codegen/client-preset': major
5+
---
6+
7+
BREAKING CHANGE: `typescript` plugin no longer generates `Exact` utility type. Instead, `typescript-operations` generates said utility type for every file it creates. This is because it is used _only_ for `Variables`, so we only need to generate it once for every generated operation file.

dev-test/external-documents/app/types.generated.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
12
export type UserQueryVariables = Exact<{
23
id: Scalars['ID']['input'];
34
}>;

dev-test/githunt/typed-document-nodes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
22

33
export type Maybe<T> = T | null;
44
export type InputMaybe<T> = Maybe<T>;
5-
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
65
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
76
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
87
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = {
@@ -11,6 +10,7 @@ export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> =
1110
export type Incremental<T> =
1211
| T
1312
| { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
13+
type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
1414
/** All built-in and custom scalars, mapped to their actual values */
1515
export type Scalars = {
1616
ID: { input: string; output: string };

dev-test/githunt/types.avoidOptionals.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export type Maybe<T> = T | null;
22
export type InputMaybe<T> = Maybe<T>;
3-
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
43
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
54
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
65
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = {
@@ -9,6 +8,7 @@ export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> =
98
export type Incremental<T> =
109
| T
1110
| { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
11+
type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
1212
/** All built-in and custom scalars, mapped to their actual values */
1313
export type Scalars = {
1414
ID: { input: string; output: string };

dev-test/githunt/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export type Maybe<T> = T | null;
22
export type InputMaybe<T> = Maybe<T>;
3-
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
43
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
54
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
65
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = {
@@ -9,6 +8,7 @@ export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> =
98
export type Incremental<T> =
109
| T
1110
| { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
11+
type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
1212
/** All built-in and custom scalars, mapped to their actual values */
1313
export type Scalars = {
1414
ID: { input: string; output: string };

dev-test/githunt/types.enumsAsTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export type Maybe<T> = T | null;
22
export type InputMaybe<T> = Maybe<T>;
3-
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
43
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
54
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
65
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = {
@@ -9,6 +8,7 @@ export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> =
98
export type Incremental<T> =
109
| T
1110
| { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
11+
type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
1212
/** All built-in and custom scalars, mapped to their actual values */
1313
export type Scalars = {
1414
ID: { input: string; output: string };

dev-test/githunt/types.flatten.preResolveTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export type Maybe<T> = T | null;
22
export type InputMaybe<T> = Maybe<T>;
3-
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
43
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
54
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
65
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = {
@@ -9,6 +8,7 @@ export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> =
98
export type Incremental<T> =
109
| T
1110
| { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
11+
type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
1212
/** All built-in and custom scalars, mapped to their actual values */
1313
export type Scalars = {
1414
ID: { input: string; output: string };

dev-test/githunt/types.immutableTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export type Maybe<T> = T | null;
22
export type InputMaybe<T> = Maybe<T>;
3-
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
43
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
54
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
65
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = {
@@ -9,6 +8,7 @@ export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> =
98
export type Incremental<T> =
109
| T
1110
| { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
11+
type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
1212
/** All built-in and custom scalars, mapped to their actual values */
1313
export type Scalars = {
1414
ID: { input: string; output: string };

dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export type Maybe<T> = T | null;
22
export type InputMaybe<T> = Maybe<T>;
3-
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
43
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
54
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
65
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = {
@@ -9,6 +8,7 @@ export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> =
98
export type Incremental<T> =
109
| T
1110
| { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
11+
type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
1212
/** All built-in and custom scalars, mapped to their actual values */
1313
export type Scalars = {
1414
ID: { input: string; output: string };

dev-test/githunt/types.preResolveTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export type Maybe<T> = T | null;
22
export type InputMaybe<T> = Maybe<T>;
3-
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
43
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
54
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
65
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = {
@@ -9,6 +8,7 @@ export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> =
98
export type Incremental<T> =
109
| T
1110
| { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
11+
type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
1212
/** All built-in and custom scalars, mapped to their actual values */
1313
export type Scalars = {
1414
ID: { input: string; output: string };

0 commit comments

Comments
 (0)