-
Notifications
You must be signed in to change notification settings - Fork 13
/
Query.ts
29 lines (24 loc) · 862 Bytes
/
Query.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { FetchError } from './FetchError'
import { JsonMap } from './JsonValue'
import { PossiblyDynamic } from './PossiblyDynamic'
import { QueryParameters } from './QueryParameters'
export type QueryVariables = Record<string, any>
export interface ResourceQuery {
resource: string
id?: PossiblyDynamic<string, QueryVariables>
data?: PossiblyDynamic<any, QueryVariables>
params?: PossiblyDynamic<QueryParameters, QueryVariables>
}
export interface ResolvedResourceQuery extends ResourceQuery {
id?: string
data?: any
params?: QueryParameters
}
export type Query = Record<string, ResourceQuery>
export type QueryResult = JsonMap
export interface QueryOptions<TQueryResult = QueryResult> {
variables?: QueryVariables
onComplete?: (data: TQueryResult) => void
onError?: (error: FetchError) => void
lazy?: boolean
}