Skip to content

Commit ddf126c

Browse files
committed
Add useSubscription
1 parent 9e06f43 commit ddf126c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/reactHooks.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ declare module "@apollo/react-hooks" {
88
MutationHookOptions,
99
MutationTuple,
1010
QueryHookOptions,
11+
SubscriptionHookOptions,
1112
} from "@apollo/react-hooks/lib/types";
1213

1314
export * from "@apollo/react-hooks/lib/index";
@@ -29,4 +30,18 @@ declare module "@apollo/react-hooks" {
2930
mutation: TypedDocumentNode<TVariables, TData>,
3031
options?: TOptions
3132
): MutationTuple<TData, TVariables>;
33+
34+
export function useSubscription<
35+
TData,
36+
TVariables extends OperationVariables,
37+
TOptions extends SubscriptionHookOptions<TData, TVariables>
38+
>(
39+
subscription: TypedDocumentNode<TVariables, TData>,
40+
options?: TOptions
41+
): {
42+
variables: TVariables | undefined;
43+
loading: boolean;
44+
data?: TData | undefined;
45+
error?: import("apollo-client").ApolloError | undefined;
46+
};
3247
}

0 commit comments

Comments
 (0)