Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gentle-suits-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-codegen/client-preset': patch
---

Add additional types to useFragment codegen for support array of nullable gql types
26 changes: 23 additions & 3 deletions dev-test/gql-tag-operations-masking/gql/fragment-masking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): Array<TType> | null | undefined;
// return nullable array of non-nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>> | null> | undefined
): Array<TType | null> | undefined;
// return nullable array of nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>> | null> | null | undefined
): Array<TType | null> | null | undefined;
// return readonly array of non-nullable if `fragmentType` is array of non-nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
Expand All @@ -52,15 +62,25 @@ export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): ReadonlyArray<TType> | null | undefined;
// return nullable readonly array of non-nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null> | undefined
): ReadonlyArray<TType | null> | undefined;
// return nullable readonly array of nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null> | null | undefined
): ReadonlyArray<TType | null> | null | undefined;
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType:
| FragmentType<DocumentTypeDecoration<TType, any>>
| Array<FragmentType<DocumentTypeDecoration<TType, any>>>
| ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
| Array<FragmentType<DocumentTypeDecoration<TType, any>> | null>
| ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null>
| null
| undefined
): TType | Array<TType> | ReadonlyArray<TType> | null | undefined {
): TType | Array<TType | null> | ReadonlyArray<TType | null> | null | undefined {
return fragmentType as any;
}

Expand Down
26 changes: 23 additions & 3 deletions dev-test/gql-tag-operations-urql/gql/fragment-masking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): Array<TType> | null | undefined;
// return nullable array of non-nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>> | null> | undefined
): Array<TType | null> | undefined;
// return nullable array of nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>> | null> | null | undefined
): Array<TType | null> | null | undefined;
// return readonly array of non-nullable if `fragmentType` is array of non-nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
Expand All @@ -52,15 +62,25 @@ export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): ReadonlyArray<TType> | null | undefined;
// return nullable readonly array of non-nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null> | undefined
): ReadonlyArray<TType | null> | undefined;
// return nullable readonly array of nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null> | null | undefined
): ReadonlyArray<TType | null> | null | undefined;
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType:
| FragmentType<DocumentTypeDecoration<TType, any>>
| Array<FragmentType<DocumentTypeDecoration<TType, any>>>
| ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
| Array<FragmentType<DocumentTypeDecoration<TType, any>> | null>
| ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null>
| null
| undefined
): TType | Array<TType> | ReadonlyArray<TType> | null | undefined {
): TType | Array<TType | null> | ReadonlyArray<TType | null> | null | undefined {
return fragmentType as any;
}

Expand Down
26 changes: 23 additions & 3 deletions dev-test/gql-tag-operations/gql/fragment-masking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): Array<TType> | null | undefined;
// return nullable array of non-nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>> | null> | undefined
): Array<TType | null> | undefined;
// return nullable array of nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>> | null> | null | undefined
): Array<TType | null> | null | undefined;
// return readonly array of non-nullable if `fragmentType` is array of non-nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
Expand All @@ -52,15 +62,25 @@ export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): ReadonlyArray<TType> | null | undefined;
// return nullable readonly array of non-nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null> | undefined
): ReadonlyArray<TType | null> | undefined;
// return nullable readonly array of nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null> | null | undefined
): ReadonlyArray<TType | null> | null | undefined;
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType:
| FragmentType<DocumentTypeDecoration<TType, any>>
| Array<FragmentType<DocumentTypeDecoration<TType, any>>>
| ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
| Array<FragmentType<DocumentTypeDecoration<TType, any>> | null>
| ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null>
| null
| undefined
): TType | Array<TType> | ReadonlyArray<TType> | null | undefined {
): TType | Array<TType | null> | ReadonlyArray<TType | null> | null | undefined {
return fragmentType as any;
}

Expand Down
26 changes: 23 additions & 3 deletions dev-test/gql-tag-operations/graphql/fragment-masking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): Array<TType> | null | undefined;
// return nullable array of non-nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>> | null> | undefined
): Array<TType | null> | undefined;
// return nullable array of nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>> | null> | null | undefined
): Array<TType | null> | null | undefined;
// return readonly array of non-nullable if `fragmentType` is array of non-nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
Expand All @@ -52,15 +62,25 @@ export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): ReadonlyArray<TType> | null | undefined;
// return nullable readonly array of non-nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null> | undefined
): ReadonlyArray<TType | null> | undefined;
// return nullable readonly array of nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null> | null | undefined
): ReadonlyArray<TType | null> | null | undefined;
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType:
| FragmentType<DocumentTypeDecoration<TType, any>>
| Array<FragmentType<DocumentTypeDecoration<TType, any>>>
| ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
| Array<FragmentType<DocumentTypeDecoration<TType, any>> | null>
| ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null>
| null
| undefined
): TType | Array<TType> | ReadonlyArray<TType> | null | undefined {
): TType | Array<TType | null> | ReadonlyArray<TType | null> | null | undefined {
return fragmentType as any;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): Array<TType> | null | undefined;
// return nullable array of non-nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>> | null> | undefined
): Array<TType | null> | undefined;
// return nullable array of nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>> | null> | null | undefined
): Array<TType | null> | null | undefined;
// return readonly array of non-nullable if `fragmentType` is array of non-nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
Expand All @@ -51,15 +61,25 @@ export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): ReadonlyArray<TType> | null | undefined;
// return nullable readonly array of non-nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null> | undefined
): ReadonlyArray<TType | null> | undefined;
// return nullable readonly array of nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null> | null | undefined
): ReadonlyArray<TType | null> | null | undefined;
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType:
| FragmentType<DocumentTypeDecoration<TType, any>>
| Array<FragmentType<DocumentTypeDecoration<TType, any>>>
| ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
| Array<FragmentType<DocumentTypeDecoration<TType, any>> | null>
| ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null>
| null
| undefined
): TType | Array<TType> | ReadonlyArray<TType> | null | undefined {
): TType | Array<TType | null> | ReadonlyArray<TType | null> | null | undefined {
return fragmentType as any;
}

Expand Down
26 changes: 23 additions & 3 deletions examples/persisted-documents/src/gql/fragment-masking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): Array<TType> | null | undefined;
// return nullable array of non-nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>> | null> | undefined
): Array<TType | null> | undefined;
// return nullable array of nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>> | null> | null | undefined
): Array<TType | null> | null | undefined;
// return readonly array of non-nullable if `fragmentType` is array of non-nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
Expand All @@ -52,15 +62,25 @@ export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): ReadonlyArray<TType> | null | undefined;
// return nullable readonly array of non-nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null> | undefined
): ReadonlyArray<TType | null> | undefined;
// return nullable readonly array of nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null> | null | undefined
): ReadonlyArray<TType | null> | null | undefined;
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType:
| FragmentType<DocumentTypeDecoration<TType, any>>
| Array<FragmentType<DocumentTypeDecoration<TType, any>>>
| ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
| Array<FragmentType<DocumentTypeDecoration<TType, any>> | null>
| ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null>
| null
| undefined
): TType | Array<TType> | ReadonlyArray<TType> | null | undefined {
): TType | Array<TType | null> | ReadonlyArray<TType | null> | null | undefined {
return fragmentType as any;
}

Expand Down
26 changes: 23 additions & 3 deletions examples/react/apollo-client-defer/src/gql/fragment-masking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): Array<TType> | null | undefined;
// return nullable array of non-nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>> | null> | undefined
): Array<TType | null> | undefined;
// return nullable array of nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>> | null> | null | undefined
): Array<TType | null> | null | undefined;
// return readonly array of non-nullable if `fragmentType` is array of non-nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
Expand All @@ -52,15 +62,25 @@ export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
): ReadonlyArray<TType> | null | undefined;
// return nullable readonly array of non-nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null> | undefined
): ReadonlyArray<TType | null> | undefined;
// return nullable readonly array of nullable if `fragmentType` is nullable array of nullable
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null> | null | undefined
): ReadonlyArray<TType | null> | null | undefined;
export function useFragment<TType>(
_documentNode: DocumentTypeDecoration<TType, any>,
fragmentType:
| FragmentType<DocumentTypeDecoration<TType, any>>
| Array<FragmentType<DocumentTypeDecoration<TType, any>>>
| ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
| Array<FragmentType<DocumentTypeDecoration<TType, any>> | null>
| ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>> | null>
| null
| undefined
): TType | Array<TType> | ReadonlyArray<TType> | null | undefined {
): TType | Array<TType | null> | ReadonlyArray<TType | null> | null | undefined {
return fragmentType as any;
}

Expand Down
Loading
Loading