Skip to content

Commit

Permalink
Fixes for subscription generics in urql plugin (#4195)
Browse files Browse the repository at this point in the history
Co-authored-by: Pytal <[email protected]>
  • Loading branch information
dotansimha and Pytal authored Jun 9, 2020
1 parent a841e8b commit 2e49bc0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/plugins/typescript/urql/src/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function use${operationName}() {

if (operationType === 'Subscription') {
return `
export function use${operationName}<TData = any>(options: Omit<Urql.Use${operationType}Args<${operationVariablesTypes}>, 'query'> = {}, handler?: Urql.SubscriptionHandler<${operationResultType}, TData>) {
export function use${operationName}<TData = ${operationResultType}>(options: Omit<Urql.Use${operationType}Args<${operationVariablesTypes}>, 'query'> = {}, handler?: Urql.SubscriptionHandler<${operationResultType}, TData>) {
return Urql.use${operationType}<${operationResultType}, TData, ${operationVariablesTypes}>({ query: ${documentVariableName}, ...options }, handler);
};`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const ListenToCommentsDocument = gql\`
}
\`;
export function useListenToCommentsSubscription<TData = any>(options: Omit<Urql.UseSubscriptionArgs<ListenToCommentsSubscriptionVariables>, 'query'> = {}, handler?: Urql.SubscriptionHandler<ListenToCommentsSubscription, TData>) {
export function useListenToCommentsSubscription<TData = ListenToCommentsSubscription>(options: Omit<Urql.UseSubscriptionArgs<ListenToCommentsSubscriptionVariables>, 'query'> = {}, handler?: Urql.SubscriptionHandler<ListenToCommentsSubscription, TData>) {
return Urql.useSubscription<ListenToCommentsSubscription, TData, ListenToCommentsSubscriptionVariables>({ query: ListenToCommentsDocument, ...options }, handler);
};"
`;
2 changes: 1 addition & 1 deletion packages/plugins/typescript/urql/tests/urql.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ export function useSubmitRepositoryMutation() {
)) as Types.ComplexPluginOutput;

expect(content.content).toBeSimilarStringTo(`
export function useListenToCommentsSubscription<TData = any>(options: Omit<Urql.UseSubscriptionArgs<ListenToCommentsSubscriptionVariables>, 'query'> = {}, handler?: Urql.SubscriptionHandler<ListenToCommentsSubscription, TData>) {
export function useListenToCommentsSubscription<TData = ListenToCommentsSubscription>(options: Omit<Urql.UseSubscriptionArgs<ListenToCommentsSubscriptionVariables>, 'query'> = {}, handler?: Urql.SubscriptionHandler<ListenToCommentsSubscription, TData>) {
return Urql.useSubscription<ListenToCommentsSubscription, TData, ListenToCommentsSubscriptionVariables>({ query: ListenToCommentsDocument, ...options }, handler);
};`);
await validateTypeScript(content, schema, docs, {});
Expand Down

0 comments on commit 2e49bc0

Please sign in to comment.