TS2742

error TS2742: The inferred type of ‘ProductDeleteDocument‘ cannot be named without a reference to ‘graphql-tag/node_modules/graphql/language/ast‘. This is likely not portable. A type annotation is necessary.

Broken Code ❌

1
2
3
4
5
6
7
export const ProductDeleteDocument = gql`
mutation ProductDelete($productId: ID!) {
productDelete(input: { id: $productId }) {
deletedProductId
}
}
`;

Fixed Code ✔️

TypeScript asks for a type annotation to explicitly resolve the inferred type, so let’s add a type annotation:

1
2
3
4
5
6
7
8
9
import {DocumentNode} from 'graphql';

export const ProductDeleteDocument: DocumentNode = gql`
mutation ProductDelete($productId: ID!) {
productDelete(input: { id: $productId }) {
deletedProductId
}
}
`;