Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding support for response headers #35

Merged
merged 11 commits into from
Oct 23, 2024
2 changes: 1 addition & 1 deletion packages/plugin-react-query/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@harnessio/oats-plugin-react-query",
"version": "3.1.0",
"version": "4.0.0",
"license": "MIT",
"type": "module",
"repository": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ Omit<FetcherOptions<
{%- endif %}
}

export function {{fetcherName}}(props: {{fetcherPropsName}}): Promise<{{okResponseName}}> {
export interface {{fetcherPropsName}}ReturnValue {
vardanbansal-harness marked this conversation as resolved.
Show resolved Hide resolved
content: {{okResponseName}}
headers: Record<string, any>
vardanbansal-harness marked this conversation as resolved.
Show resolved Hide resolved
}

export function {{fetcherName}}(props: {{fetcherPropsName}}): Promise<{{fetcherPropsName}}ReturnValue> {
return fetcher<
{{okResponseName}},
{% if queryParamsCode -%}{{queryParamsName}}{% else %}unknown{%- endif %},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ export type {{mutationPropsName}}<T extends keyof {{fetcherPropsName}}> = Omit<{
{{description}}
export function {{hookName}}<T extends keyof {{fetcherPropsName}}>(
props: Pick<Partial<{{fetcherPropsName}}>, T>,
options?: Omit<UseMutationOptions<{{okResponseName}}, {{errorResponseName}}, {{mutationPropsName}}<T>>, 'mutationKey' | 'mutationFn'>
options?: Omit<UseMutationOptions<{{fetcherPropsName}}ReturnValue, {{errorResponseName}}, {{mutationPropsName}}<T>>, 'mutationKey' | 'mutationFn'>
) {
return useMutation<
{{okResponseName}},
{{fetcherPropsName}}ReturnValue,
{{errorResponseName}},
{{mutationPropsName}}<T>
>(
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-react-query/src/templates/useQueryHook.liquid
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{description}}
export function {{hookName}}(
props: {{fetcherPropsName}},
options?: Omit<UseQueryOptions<{{okResponseName}}, {{errorResponseName}}>, 'queryKey' | 'queryFn'>
options?: Omit<UseQueryOptions<{{fetcherPropsName}}ReturnValue, {{errorResponseName}}>, 'queryKey' | 'queryFn'>
) {
return useQuery<{{okResponseName}}, {{errorResponseName}}>(
return useQuery<{{fetcherPropsName}}ReturnValue, {{errorResponseName}}>(
[
{{operation.operationId | json}}
{% if pathParamsCode -%}
Expand Down
Loading