Skip to content

Commit

Permalink
Merge pull request #89 from basehub-ai/jb/no-store-in-draft-mode
Browse files Browse the repository at this point in the history
cache no store in draft mode
  • Loading branch information
julianbenegas authored Apr 9, 2024
2 parents 715b7d8 + b0d2975 commit 97f11d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/strong-radios-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"basehub": patch
---

cache no store in draft mode
7 changes: 5 additions & 2 deletions packages/basehub/src/bin/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const main = async (args: Args, opts?: { forceDraft?: boolean }) => {
);

// 3. append our basehub function to the end of the file.
const basehubExport = getBaseHubExport(draft);
if (!schemaFileContents.includes(basehubExport)) {
schemaFileContents = schemaFileContents.concat(`\n${basehubExport}`);
}
Expand Down Expand Up @@ -227,7 +228,7 @@ export const main = async (args: Args, opts?: { forceDraft?: boolean }) => {
}
};

const basehubExport = `
const getBaseHubExport = (noStore: boolean) => `
export * from "@basehub/mutation-api-helpers";
import { createFetcher } from "./runtime";
Expand All @@ -254,7 +255,9 @@ export const basehub = (options?: Options) => {
const { url, headers } = getStuffFromEnv(options);
return {
...createClient(options),
...createClient(${
noStore ? "{ ...options, cache: 'no-store' }" : "options"
}),
raw: createFetcher({ ...options, url, headers }) as <Cast = unknown>(
gql: GraphqlOperation
) => Promise<Cast>,
Expand Down

0 comments on commit 97f11d2

Please sign in to comment.