Skip to content

Commit

Permalink
Partial queryResult's contents
Browse files Browse the repository at this point in the history
  • Loading branch information
jtoar committed Apr 30, 2023
1 parent 2e40dc8 commit ee3e0a9
Showing 1 changed file with 21 additions and 27 deletions.
48 changes: 21 additions & 27 deletions packages/web/src/components/createCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,23 @@ export type CellProps<
CellPropsVariables<CellType, GQLVariables>
>

export type CellLoadingProps<TVariables extends OperationVariables = any> =
Partial<{
queryResult: Omit<
QueryOperationResult<any, TVariables>,
'loading' | 'error' | 'data'
>
}>
export type CellLoadingProps<TVariables extends OperationVariables = any> = {
queryResult: Partial<
Omit<QueryOperationResult<any, TVariables>, 'loading' | 'error' | 'data'>
>
}

export type CellFailureProps<TVariables extends OperationVariables = any> =
Partial<{
queryResult: Omit<
QueryOperationResult<any, TVariables>,
'loading' | 'error' | 'data'
>
error: QueryOperationResult['error'] | Error // for tests and storybook
/**
* @see {@link https://www.apollographql.com/docs/apollo-server/data/errors/#error-codes}
*/
errorCode: string
updating: boolean
}>
export type CellFailureProps<TVariables extends OperationVariables = any> = {
queryResult: Partial<
Omit<QueryOperationResult<any, TVariables>, 'loading' | 'error' | 'data'>
>
error?: QueryOperationResult['error'] | Error // for tests and storybook
/**
* @see {@link https://www.apollographql.com/docs/apollo-server/data/errors/#error-codes}
*/
errorCode?: string
updating?: boolean
}

// aka guarantee that all properties in T exist
// This is necessary for Cells, because if it doesn't exist it'll go to Empty or Failure
Expand Down Expand Up @@ -106,14 +102,12 @@ export type CellSuccessData<TData = any> = Omit<Guaranteed<TData>, '__typename'>
export type CellSuccessProps<
TData = any,
TVariables extends OperationVariables = any
> = Partial<{
queryResult: Omit<
QueryOperationResult<TData, TVariables>,
'loading' | 'error' | 'data'
> = {
queryResult: Partial<
Omit<QueryOperationResult<TData, TVariables>, 'loading' | 'error' | 'data'>
>
updating: boolean
}> &
A.Compute<CellSuccessData<TData>> // pre-computing makes the types more readable on hover
updating?: boolean
} & A.Compute<CellSuccessData<TData>> // pre-computing makes the types more readable on hover

/**
* A coarse type for the `data` prop returned by `useQuery`.
Expand Down

0 comments on commit ee3e0a9

Please sign in to comment.