Updated types

This commit is contained in:
Luis Alvarez
2020-10-19 12:52:09 -05:00
parent 9309bff517
commit f4bc27666b
7 changed files with 24 additions and 28 deletions

View File

@@ -1,7 +1,7 @@
import type {
GetAllProductsQuery,
GetAllProductsQueryVariables,
} from 'lib/bigcommerce/schema'
} from '@lib/bigcommerce/schema'
import type { RecursivePartial, RecursiveRequired } from '../utils/types'
import filterEdges from '../utils/filter-edges'
import { productConnectionFragment } from '../fragments/product'
@@ -47,12 +47,12 @@ export type ProductEdge = NonNullable<
NonNullable<GetAllProductsQuery['site']['products']['edges']>[0]
>
export type Product = ProductEdge
export type Products = ProductEdge[]
export type ProductNode = ProductEdge['node']
export type GetAllProductsResult<
T extends Record<keyof GetAllProductsResult, any[]> = { products: Products }
T extends Record<keyof GetAllProductsResult, any[]> = {
products: ProductEdge[]
}
> = T
const FIELDS = [

View File

@@ -33,13 +33,13 @@ export const getProductQuery = /* GraphQL */ `
${productInfoFragment}
`
export type Product = Extract<
export type ProductNode = Extract<
GetProductQuery['site']['route']['node'],
{ __typename: 'Product' }
>
export type GetProductResult<
T extends { product?: any } = { product?: Product }
T extends { product?: any } = { product?: ProductNode }
> = T
export type ProductVariables = Images &