From 968e8e5fa2074ff93b2bdc193218a7396e2e1aa5 Mon Sep 17 00:00:00 2001 From: Tomoya Kashifuku Date: Sun, 15 Oct 2023 13:06:35 +0900 Subject: [PATCH] update snapshot --- .../client/tests/client-preset.spec.ts | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/packages/presets/client/tests/client-preset.spec.ts b/packages/presets/client/tests/client-preset.spec.ts index fdf897883b5d..ac560d3a3595 100644 --- a/packages/presets/client/tests/client-preset.spec.ts +++ b/packages/presets/client/tests/client-preset.spec.ts @@ -754,11 +754,21 @@ export * from "./gql";`); expect(result).toHaveLength(4); const gqlFile = result.find(file => file.filename === 'out1/fragment-masking.ts'); expect(gqlFile.content).toMatchInlineSnapshot(` - "import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core'; + "import { DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core'; import { FragmentDefinitionNode } from 'graphql'; import { Incremental } from './graphql'; + type Primitive = string | number | boolean | bigint | symbol | null | undefined; + type ExcludePrimitive = Exclude; + type ExtractPrimitive = Exclude>; + type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ( + k: infer I + ) => void + ? I + : never; + + export type FragmentType> = TDocumentType extends DocumentTypeDecoration< infer TType, any @@ -798,10 +808,43 @@ export * from "./gql";`); } + type UnionToIntersectGroupByTypeName = [V] extends [ + { __typename?: infer TypeName } + ] + ? TypeName extends any + ? UnionToIntersection + : never + : never; + + type UnionFieldToIntersection = [T] extends [never] ? never + : [T] extends [Array] + ? Array< + | UnionFieldToIntersection> + | ExtractPrimitive + > + : UnionToIntersectGroupByTypeName extends infer V + ? { + [Key in keyof V]: + | UnionFieldToIntersection> + | ExtractPrimitive; + } + : never; + + type Flatten = [F] extends [never] ? never + : F extends Array + ? Array> | ExtractPrimitive> + : { + [Key in keyof Omit]: + | Flatten> + | ExtractPrimitive; + } & (F extends { " $fragmentRefs"?: { [K in string]: infer FRefs }; } + ? (FRefs extends any ? Flatten : never) : {} + ); + export type UnmaskFragment = UnionFieldToIntersection>; + export function makeFragmentData< F extends DocumentTypeDecoration, - FT extends ResultOf - >(data: FT, _fragment: F): FragmentType { + >(data: UnmaskFragment>, _fragment: F): FragmentType { return data as FragmentType; } export function isFragmentReady(