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

document fetchOptions #206

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions 030-Concepts/075-file-attachments.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ Within the Xata UI you can make files public by default for the column by settin
![Entire columns can be made public by default](images/column-access-public.png)

<Alert status="warning">
**Public object caching** Changing the permissions of a cached public object does not remove it from the cache. The cached version remains unaffected.
The file remains accessible through the previously existing URLs until the cache expires after 2 hours. It is highly recommended to exercise caution when
configuring public access. There is a significant delay in reverting permissions from public back to
private.
**Public object caching** Changing the permissions of a cached public object does not remove it from the cache. The
cached version remains unaffected. The file remains accessible through the previously existing URLs until the cache
expires after 2 hours. It is highly recommended to exercise caution when configuring public access. There is a
significant delay in reverting permissions from public back to private.
</Alert>

### Signed URLs
Expand Down
18 changes: 18 additions & 0 deletions 040-SDK/010-TypeScript/020-configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ const xata = new XataClient({ apiKey: XATA_API_KEY });

In case your runtime does not provide a built-in Fetch API (such as with versions prior to Node 18), you will need to pass a fetch implementation to the `fetch ` constructor parameter of the XataClient in the `xata.ts` / `xata.js `file in your project.

## Passing options to fetch

Some frameworks, such as Next.js, support additional fetch options. These settings allow you to specifically control how caching and revalidation are handled for each fetch operation on the server.

The Xata SDK supports the `fetchOptions` parameter for passing options to fetch.

This parameter can be used to configure cache revalidation at a timed interval:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd make this more clear it's only for Next.js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add clarifications once we have findings from xataio/client-ts#1311 as it doesn't seem to actually work as documented, maybe there's more steps needed in Next.js.


```ts
const records = xata.db.users.getMany({ pagination: { size: 10 }, fetchOptions: { next: { revalidate: '3060' } } });
```

or, to disable the cache for a fetch request:

```ts
const records = xata.db.users.getMany({ pagination: { size: 10 }, fetchOptions: { cache: 'no-store' } });
```

## Updating the schema

The command `xata codegen` updates the schema for the Xata client. Applying schema changes from the CLI, such as using the command `xata schema edit`, will automatically run codegen to update your client. However, in case schema changes have been applied from the web UI, you should run `xata codegen` to update your existing client with the latest schema.