@@ -6029,4 +6029,93 @@ function test(q: GetEntityBrandDataQuery): void {
6029
6029
);
6030
6030
` ) ;
6031
6031
} ) ;
6032
+
6033
+ describe ( 'inlineFragmentTypes option' , ( ) => {
6034
+ it ( "'combine' yields correct types" , async ( ) => {
6035
+ const ast = parse ( /* GraphQL */ `
6036
+ query {
6037
+ me {
6038
+ ...UserFragment
6039
+ }
6040
+ }
6041
+ fragment UserFragment on User {
6042
+ id
6043
+ }
6044
+ ` ) ;
6045
+ const result = await plugin (
6046
+ schema ,
6047
+ [ { location : 'test-file.ts' , document : ast } ] ,
6048
+ { inlineFragmentTypes : 'combine' } ,
6049
+ { outputFile : '' }
6050
+ ) ;
6051
+ expect ( result . content ) . toBeSimilarStringTo ( `
6052
+ export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>;
6053
+
6054
+
6055
+ export type Unnamed_1_Query = { __typename?: 'Query', me?: (
6056
+ { __typename?: 'User' }
6057
+ & UserFragmentFragment
6058
+ ) | null };
6059
+
6060
+ export type UserFragmentFragment = { __typename?: 'User', id: string };
6061
+ ` ) ;
6062
+ } ) ;
6063
+
6064
+ it ( "'inline' yields correct types" , async ( ) => {
6065
+ const ast = parse ( /* GraphQL */ `
6066
+ query {
6067
+ me {
6068
+ ...UserFragment
6069
+ }
6070
+ }
6071
+ fragment UserFragment on User {
6072
+ id
6073
+ }
6074
+ ` ) ;
6075
+ const result = await plugin (
6076
+ schema ,
6077
+ [ { location : 'test-file.ts' , document : ast } ] ,
6078
+ { inlineFragmentTypes : 'inline' } ,
6079
+ { outputFile : '' }
6080
+ ) ;
6081
+ expect ( result . content ) . toBeSimilarStringTo ( `
6082
+ export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>;
6083
+
6084
+
6085
+ export type Unnamed_1_Query = { __typename?: 'Query', me?: { __typename?: 'User', id: string } | null };
6086
+
6087
+ export type UserFragmentFragment = { __typename?: 'User', id: string };
6088
+ ` ) ;
6089
+ } ) ;
6090
+
6091
+ it ( "'mask' yields correct types" , async ( ) => {
6092
+ const ast = parse ( /* GraphQL */ `
6093
+ query {
6094
+ me {
6095
+ ...UserFragment
6096
+ }
6097
+ }
6098
+ fragment UserFragment on User {
6099
+ id
6100
+ }
6101
+ ` ) ;
6102
+ const result = await plugin (
6103
+ schema ,
6104
+ [ { location : 'test-file.ts' , document : ast } ] ,
6105
+ { inlineFragmentTypes : 'mask' } ,
6106
+ { outputFile : '' }
6107
+ ) ;
6108
+ expect ( result . content ) . toBeSimilarStringTo ( `
6109
+ export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>;
6110
+
6111
+
6112
+ export type Unnamed_1_Query = { __typename?: 'Query', me?: (
6113
+ { __typename?: 'User' }
6114
+ & { ' $fragmentRefs': { 'UserFragmentFragment': UserFragmentFragment } }
6115
+ ) | null };
6116
+
6117
+ export type UserFragmentFragment = { __typename?: 'User', id: string } & { ' $fragmentName': 'UserFragmentFragment' };
6118
+ ` ) ;
6119
+ } ) ;
6120
+ } ) ;
6032
6121
} ) ;
0 commit comments