Skip to content

Commit

Permalink
setURL and setOptions in onFetch hook (#6608)
Browse files Browse the repository at this point in the history
  • Loading branch information
enisdenjo authored Feb 28, 2024
1 parent 2600819 commit 92dce67
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/metal-parrots-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@graphql-mesh/types": minor
"@graphql-mesh/utils": minor
---

setURL and setOptions in onFetch hook
2 changes: 2 additions & 0 deletions packages/legacy/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ export type MeshFetchRequestInit = Omit<RequestInit, 'headers'> & {

export interface OnFetchHookPayload<TContext> {
url: string;
setURL(url: URL | string): void;
options: MeshFetchRequestInit;
setOptions(options: MeshFetchRequestInit): void;
context: TContext;
info: GraphQLResolveInfo;
fetchFn: MeshFetch;
Expand Down
6 changes: 6 additions & 0 deletions packages/legacy/utils/src/wrapFetchWithHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ export function wrapFetchWithHooks<TContext>(onFetchHooks: OnFetchHook<TContext>
fetchFn,
setFetchFn,
url,
setURL(newUrl) {
url = String(newUrl);
},
options,
setOptions(newOptions) {
options = newOptions;
},
context,
info,
}),
Expand Down

0 comments on commit 92dce67

Please sign in to comment.