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

Add ability to pass additional options to postgrest #74

Merged
merged 3 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,19 @@ You can then start the application in `development` mode with:
make run
```

### Testing Invitations And Password Reset
Log in with the following credentials:

- Email: `[email protected]`
- Password: `password`

If you need debug the backend, you can access the following services:

- Supabase dashboard: [http://localhost:54323/](http://localhost:54323/)
- REST API: [http://127.0.0.1:54321](http://127.0.0.1:54321)
- Attachments storage: [http://localhost:54323/project/default/storage/buckets/attachments](http://localhost:54323/project/default/storage/buckets/attachments)
- Inbucket email testing service: [http://localhost:54324/](http://localhost:54324/)

### Testing Invitations And Password Reset

The current version of supabase CLI does not allow to customize the emails sent for invitation or password reset.

Expand Down
10 changes: 7 additions & 3 deletions packages/ra-supabase-core/src/dataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import postgrestRestProvider, {
defaultPrimaryKeys,
defaultSchema,
} from '@raphiniert/ra-data-postgrest';
import { SupabaseClient } from '@supabase/supabase-js';
import { createClient } from '@supabase/supabase-js';
import type { SupabaseClient } from '@supabase/supabase-js';

/**
* A function that returns a dataProvider for Supabase.
* @param instanceUrl The URL of the Supabase instance
* @param apiKey The API key of the Supabase instance. Prefer the anonymous key.
* @param supabaseClient The Supabase client
* @param httpClient Optional - The httpClient to use. Defaults to a httpClient that handles the authentication.
* @param defaultListOp Optional - The default list filter operator. Defaults to 'eq'.
* @param primaryKeys Optional - The primary keys of the tables. Defaults to 'id'.
* @param schema Optional - The custom schema to use. Defaults to none.
Expand All @@ -19,22 +21,24 @@ import { SupabaseClient } from '@supabase/supabase-js';
export const supabaseDataProvider = ({
instanceUrl,
apiKey,
supabaseClient,
supabaseClient = createClient(instanceUrl, apiKey),
httpClient = supabaseHttpClient({ apiKey, supabaseClient }),
defaultListOp = 'eq',
primaryKeys = defaultPrimaryKeys,
schema = defaultSchema,
...rest
}: {
instanceUrl: string;
apiKey: string;
supabaseClient: SupabaseClient;
supabaseClient?: SupabaseClient;
} & Partial<Omit<IDataProviderConfig, 'apiUrl'>>): DataProvider => {
const config: IDataProviderConfig = {
apiUrl: `${instanceUrl}/rest/v1`,
httpClient,
defaultListOp,
primaryKeys,
schema,
...rest,
};
return postgrestRestProvider(config);
};
Expand Down
Loading