@@ -7423,5 +7423,168 @@ function test(q: GetEntityBrandDataQuery): void {
7423
7423
export type UserFragmentFragment = { __typename?: 'User', id: string } & { ' $fragmentName'?: 'UserFragmentFragment' };
7424
7424
` ) ;
7425
7425
} ) ;
7426
+
7427
+ it ( "'mask' with @unmask configured with apolloUnmask yields correct types" , async ( ) => {
7428
+ const ast = parse ( /* GraphQL */ `
7429
+ query {
7430
+ me {
7431
+ ...UserFragment @unmask
7432
+ }
7433
+ }
7434
+ fragment UserFragment on User {
7435
+ id
7436
+ }
7437
+ ` ) ;
7438
+ const result = await plugin (
7439
+ schema ,
7440
+ [ { location : 'test-file.ts' , document : ast } ] ,
7441
+ { inlineFragmentTypes : 'mask' , customDirectives : { apolloUnmask : true } } ,
7442
+ { outputFile : '' }
7443
+ ) ;
7444
+ expect ( result . content ) . toBeSimilarStringTo ( `
7445
+ export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>;
7446
+
7447
+
7448
+ export type Unnamed_1_Query = { __typename?: 'Query', me?: (
7449
+ { __typename?: 'User', id: string }
7450
+ & { ' $fragmentRefs'?: { 'UserFragmentFragment': UserFragmentFragment } }
7451
+ ) | null };
7452
+
7453
+ export type UserFragmentFragment = { __typename?: 'User', id: string } & { ' $fragmentName'?: 'UserFragmentFragment' };
7454
+ ` ) ;
7455
+ } ) ;
7456
+
7457
+ it ( "'mask' with @unmask without apolloUnmask yields correct types" , async ( ) => {
7458
+ const ast = parse ( /* GraphQL */ `
7459
+ query {
7460
+ me {
7461
+ ...UserFragment @unmask
7462
+ }
7463
+ }
7464
+ fragment UserFragment on User {
7465
+ id
7466
+ }
7467
+ ` ) ;
7468
+ const result = await plugin (
7469
+ schema ,
7470
+ [ { location : 'test-file.ts' , document : ast } ] ,
7471
+ { inlineFragmentTypes : 'mask' } ,
7472
+ { outputFile : '' }
7473
+ ) ;
7474
+ expect ( result . content ) . toBeSimilarStringTo ( `
7475
+ export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>;
7476
+
7477
+
7478
+ export type Unnamed_1_Query = { __typename?: 'Query', me?: (
7479
+ { __typename?: 'User' }
7480
+ & { ' $fragmentRefs'?: { 'UserFragmentFragment': UserFragmentFragment } }
7481
+ ) | null };
7482
+
7483
+ export type UserFragmentFragment = { __typename?: 'User', id: string } & { ' $fragmentName'?: 'UserFragmentFragment' };
7484
+ ` ) ;
7485
+ } ) ;
7486
+
7487
+ it ( "'mask' with @unmask with apolloUnmask explicitly disabled yields correct types" , async ( ) => {
7488
+ const ast = parse ( /* GraphQL */ `
7489
+ query {
7490
+ me {
7491
+ ...UserFragment @unmask
7492
+ }
7493
+ }
7494
+ fragment UserFragment on User {
7495
+ id
7496
+ }
7497
+ ` ) ;
7498
+ const result = await plugin (
7499
+ schema ,
7500
+ [ { location : 'test-file.ts' , document : ast } ] ,
7501
+ { inlineFragmentTypes : 'mask' , customDirectives : { apolloUnmask : false } } ,
7502
+ { outputFile : '' }
7503
+ ) ;
7504
+ expect ( result . content ) . toBeSimilarStringTo ( `
7505
+ export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>;
7506
+
7507
+
7508
+ export type Unnamed_1_Query = { __typename?: 'Query', me?: (
7509
+ { __typename?: 'User' }
7510
+ & { ' $fragmentRefs'?: { 'UserFragmentFragment': UserFragmentFragment } }
7511
+ ) | null };
7512
+
7513
+ export type UserFragmentFragment = { __typename?: 'User', id: string } & { ' $fragmentName'?: 'UserFragmentFragment' };
7514
+ ` ) ;
7515
+ } ) ;
7516
+
7517
+ it ( "'mask' with @unmask and masked fragments yields correct types" , async ( ) => {
7518
+ const ast = parse ( /* GraphQL */ `
7519
+ query {
7520
+ me {
7521
+ ...UserFragment @unmask
7522
+ ...UserFragment2
7523
+ }
7524
+ }
7525
+ fragment UserFragment on User {
7526
+ id
7527
+ }
7528
+
7529
+ fragment UserFragment2 on User {
7530
+ email
7531
+ }
7532
+ ` ) ;
7533
+ const result = await plugin (
7534
+ schema ,
7535
+ [ { location : 'test-file.ts' , document : ast } ] ,
7536
+ { inlineFragmentTypes : 'mask' , customDirectives : { apolloUnmask : true } } ,
7537
+ { outputFile : '' }
7538
+ ) ;
7539
+ expect ( result . content ) . toBeSimilarStringTo ( `
7540
+ export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>;
7541
+
7542
+
7543
+ export type Unnamed_1_Query = { __typename?: 'Query', me?: (
7544
+ { __typename?: 'User', id: string }
7545
+ & { ' $fragmentRefs'?: { 'UserFragmentFragment': UserFragmentFragment;'UserFragment2Fragment': UserFragment2Fragment } }
7546
+ ) | null };
7547
+
7548
+ export type UserFragmentFragment = { __typename?: 'User', id: string } & { ' $fragmentName'?: 'UserFragmentFragment' };
7549
+ export type UserFragment2Fragment = { __typename?: 'User', email: string } & { ' $fragmentName'?: 'UserFragment2Fragment' };
7550
+ ` ) ;
7551
+ } ) ;
7552
+
7553
+ it ( "'mask' with @unmask and masked fragments on overlapping fields yields correct types" , async ( ) => {
7554
+ const ast = parse ( /* GraphQL */ `
7555
+ query {
7556
+ me {
7557
+ ...UserFragment @unmask
7558
+ ...UserFragment2
7559
+ }
7560
+ }
7561
+ fragment UserFragment on User {
7562
+ id
7563
+ email
7564
+ }
7565
+
7566
+ fragment UserFragment2 on User {
7567
+ email
7568
+ }
7569
+ ` ) ;
7570
+ const result = await plugin (
7571
+ schema ,
7572
+ [ { location : 'test-file.ts' , document : ast } ] ,
7573
+ { inlineFragmentTypes : 'mask' , customDirectives : { apolloUnmask : true } } ,
7574
+ { outputFile : '' }
7575
+ ) ;
7576
+ expect ( result . content ) . toBeSimilarStringTo ( `
7577
+ export type Unnamed_1_QueryVariables = Exact<{ [key: string]: never; }>;
7578
+
7579
+
7580
+ export type Unnamed_1_Query = { __typename?: 'Query', me?: (
7581
+ { __typename?: 'User', id: string, email: string }
7582
+ & { ' $fragmentRefs'?: { 'UserFragmentFragment': UserFragmentFragment;'UserFragment2Fragment': UserFragment2Fragment } }
7583
+ ) | null };
7584
+
7585
+ export type UserFragmentFragment = { __typename?: 'User', id: string, email: string } & { ' $fragmentName'?: 'UserFragmentFragment' };
7586
+ export type UserFragment2Fragment = { __typename?: 'User', email: string } & { ' $fragmentName'?: 'UserFragment2Fragment' };
7587
+ ` ) ;
7588
+ } ) ;
7426
7589
} ) ;
7427
7590
} ) ;
0 commit comments