graphql-hooks
Advanced tools
Comparing version 3.4.2 to 3.5.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [3.5.0](https://github.com/nearform/graphql-hooks/compare/graphql-hooks@3.4.2...graphql-hooks@3.5.0) (2019-04-12) | ||
### Features | ||
* add optional type annotations ([#202](https://github.com/nearform/graphql-hooks/issues/202)) ([6e50e04](https://github.com/nearform/graphql-hooks/commit/6e50e04)) | ||
## [3.4.2](https://github.com/nearform/graphql-hooks/compare/graphql-hooks@3.4.1...graphql-hooks@3.4.2) (2019-04-08) | ||
@@ -8,0 +19,0 @@ |
@@ -23,25 +23,31 @@ import * as React from 'react' | ||
setHeaders(headers: Headers): GraphQLClient | ||
logErrorResult({ result, operation }: { result: Result, operation: Operation }): void | ||
logErrorResult({ | ||
result, | ||
operation | ||
}: { | ||
result: Result | ||
operation: Operation | ||
}): void | ||
request(operation: Operation, options: object): Promise<Result> | ||
} | ||
export function useClientRequest( | ||
export function useClientRequest<ResponseData = any>( | ||
query: string, | ||
options?: UseClientRequestOptions | ||
): [FetchData, UseClientRequestResult] | ||
): [FetchData<ResponseData>, UseClientRequestResult<ResponseData>] | ||
export function useQuery( | ||
export function useQuery<ResponseData = any>( | ||
query: string, | ||
options?: UseQueryOptions | ||
): UseQueryResult | ||
): UseQueryResult<ResponseData> | ||
export function useManualQuery( | ||
export function useManualQuery<ResponseData = any>( | ||
query: string, | ||
options?: UseClientRequestOptions | ||
): [FetchData, UseClientRequestResult] | ||
): [FetchData<ResponseData>, UseClientRequestResult<ResponseData>] | ||
export function useMutation( | ||
export function useMutation<ResponseData = any>( | ||
query: string, | ||
options?: UseClientRequestOptions | ||
): [FetchData, UseClientRequestResult] | ||
): [FetchData<ResponseData>, UseClientRequestResult<ResponseData>] | ||
@@ -60,3 +66,9 @@ export const ClientContext: React.Context<GraphQLClient> | ||
logErrors?: boolean | ||
onError?({ result, operation }: { operation: Operation, result: Result }): void | ||
onError?({ | ||
result, | ||
operation | ||
}: { | ||
operation: Operation | ||
result: Result | ||
}): void | ||
} | ||
@@ -110,19 +122,22 @@ | ||
interface UseClientRequestResult { | ||
interface UseClientRequestResult<ResponseData> { | ||
loading: boolean | ||
cacheHit: boolean | ||
error: boolean | ||
data: any | ||
data: ResponseData | ||
fetchError?: Error | ||
httpError?: HttpError | ||
graphQLError?: object[] | ||
graphQLErrors?: object[] | ||
} | ||
interface UseQueryResult extends UseClientRequestResult { | ||
refetch(options?: UseQueryOptions): Promise<UseClientRequestResult> | ||
interface UseQueryResult<ResponseData> | ||
extends UseClientRequestResult<ResponseData> { | ||
refetch( | ||
options?: UseQueryOptions | ||
): Promise<UseClientRequestResult<ResponseData>> | ||
} | ||
type FetchData = ( | ||
type FetchData<ResponseData> = ( | ||
options?: UseClientRequestOptions | ||
) => Promise<UseClientRequestResult> | ||
) => Promise<UseClientRequestResult<ResponseData>> | ||
@@ -129,0 +144,0 @@ interface CacheKeyObject { |
{ | ||
"name": "graphql-hooks", | ||
"version": "3.4.2", | ||
"version": "3.5.0", | ||
"description": "Graphql Hooks", | ||
@@ -50,3 +50,3 @@ "main": "lib/graphql-hooks.js", | ||
"homepage": "https://github.com/nearform/graphql-hooks#readme", | ||
"gitHead": "35b29963e02f3af3632d616a08b52b35d8df75f9" | ||
"gitHead": "5f36f094d212eb90459b574d89676b01aafbd6ff" | ||
} |
93761
1644