Skip to content

Commit

Permalink
update snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
tnyo43 committed Oct 15, 2023
1 parent d79d4da commit 968e8e5
Showing 1 changed file with 46 additions and 3 deletions.
49 changes: 46 additions & 3 deletions packages/presets/client/tests/client-preset.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = Exclude<T, Primitive>;
type ExtractPrimitive<T> = Exclude<T, Exclude<T, Primitive>>;
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
k: infer I
) => void
? I
: never;
export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<
infer TType,
any
Expand Down Expand Up @@ -798,10 +808,43 @@ export * from "./gql";`);
}
type UnionToIntersectGroupByTypeName<U, V = U> = [V] extends [
{ __typename?: infer TypeName }
]
? TypeName extends any
? UnionToIntersection<U extends { __typename?: TypeName } ? U : never>
: never
: never;
type UnionFieldToIntersection<T> = [T] extends [never] ? never
: [T] extends [Array<unknown>]
? Array<
| UnionFieldToIntersection<ExcludePrimitive<T[number]>>
| ExtractPrimitive<T[number]>
>
: UnionToIntersectGroupByTypeName<T> extends infer V
? {
[Key in keyof V]:
| UnionFieldToIntersection<ExcludePrimitive<V[Key]>>
| ExtractPrimitive<V[Key]>;
}
: never;
type Flatten<F> = [F] extends [never] ? never
: F extends Array<unknown>
? Array<Flatten<ExcludePrimitive<F[number]>> | ExtractPrimitive<F[number]>>
: {
[Key in keyof Omit<F, " $fragmentRefs" | " $fragmentName">]:
| Flatten<ExcludePrimitive<F[Key]>>
| ExtractPrimitive<F[Key]>;
} & (F extends { " $fragmentRefs"?: { [K in string]: infer FRefs }; }
? (FRefs extends any ? Flatten<FRefs> : never) : {}
);
export type UnmaskFragment<F> = UnionFieldToIntersection<Flatten<F>>;
export function makeFragmentData<
F extends DocumentTypeDecoration<any, any>,
FT extends ResultOf<F>
>(data: FT, _fragment: F): FragmentType<F> {
>(data: UnmaskFragment<FragmentType<F>>, _fragment: F): FragmentType<F> {
return data as FragmentType<F>;
}
export function isFragmentReady<TQuery, TFrag>(
Expand Down

0 comments on commit 968e8e5

Please sign in to comment.