supabase_rs 0.5.0

Lightweight Rust client for Supabase REST and GraphQL
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
# Contributing to supabase_rs


Thank you for your interest in contributing to `supabase_rs`! This guide will help you get started with development, testing, and submitting contributions.

## 🎯 Project Vision


`supabase_rs` aims to provide a comprehensive, type-safe, and performant Rust SDK for Supabase. We prioritize:

- **Developer Experience**: Intuitive APIs that feel natural in Rust
- **Type Safety**: Leverage Rust's type system for compile-time guarantees
- **Performance**: Efficient query building and HTTP request handling
- **Reliability**: Comprehensive error handling and testing
- **Documentation**: Clear, comprehensive documentation with examples

## 🚀 Getting Started


### Prerequisites


- **Rust**: Latest stable version (1.70+)
- **Supabase Project**: For integration testing
- **Git**: For version control

### Development Setup


1. **Fork and Clone**
   ```bash
   git clone https://github.com/your-username/supabase_rs.git

   cd supabase_rs

   ```

2. **Environment Configuration**
   ```bash
   cp .env.example .env

   # Edit .env with your Supabase credentials for testing

   ```

3. **Install Dependencies**
   ```bash
   cargo check

   ```

4. **Run Tests**
   ```bash
   # Unit tests (no network required)

   cargo test unit_


   # Integration tests (requires Supabase credentials)

   cargo test


   # All tests with output

   cargo test -- --nocapture

   ```

## 🏗️ Project Structure


```text
supabase_rs/
├── src/
│   ├── lib.rs              # Main library entry point
│   ├── insert.rs           # Insert operations
│   ├── update.rs           # Update and upsert operations
│   ├── select.rs           # Query execution
│   ├── delete.rs           # Delete operations
│   ├── query_builder/      # Fluent query building
│   │   ├── builder.rs      # QueryBuilder implementation
│   │   ├── filter.rs       # Filter operations
│   │   └── sort.rs         # Sorting operations
│   ├── storage/            # File operations (feature-gated)
│   ├── graphql/            # GraphQL support (experimental)
│   ├── errors.rs           # Error types and handling
│   └── request/            # HTTP request utilities
├── tests/                  # Integration tests
└── docs/                   # Additional documentation
```

## 📝 Development Guidelines


### Code Style


- **Formatting**: Use `cargo fmt` for consistent formatting
- **Linting**: Run `cargo clippy` and address all warnings
- **Documentation**: Document all public APIs with examples
- **Error Handling**: Use structured error types with helpful messages

### Documentation Standards


1. **Module Documentation**: Each module should have comprehensive docs explaining:
   - Purpose and scope
   - Core features and capabilities
   - Usage examples
   - Performance considerations
   - Error handling patterns

2. **Function Documentation**: All public functions must include:
   - Clear description of functionality
   - Parameter descriptions with types
   - Return value documentation
   - At least one usage example
   - Error conditions and handling

3. **Example Requirements**:
   - Use `rust,no_run` for examples that require external setup
   - Include complete, runnable examples when possible
   - Show error handling patterns
   - Demonstrate best practices

### Testing Requirements


1. **Unit Tests**: Test individual components in isolation
   ```rust
   #[cfg(test)]
   mod tests {
       use super::*;

       #[test]
       fn test_query_building() {
           // Test query construction without network calls
       }
   }
   ```

2. **Integration Tests**: Test against live Supabase instances
   ```rust
   #[tokio::test]
   async fn test_user_crud() -> Result<(), String> {
       // Test complete CRUD operations
   }
   ```

3. **Performance Tests**: Benchmark critical operations
   ```rust
   #[tokio::test]
   async fn test_bulk_insert_performance() {
       // Measure performance of bulk operations
   }
   ```

## 🔧 Making Changes


### Feature Development


1. **Create Feature Branch**
   ```bash
   git checkout -b feature/your-feature-name

   ```

2. **Implement Changes**
   - Write code following project conventions
   - Add comprehensive documentation
   - Include relevant tests

3. **Test Thoroughly**
   ```bash
   cargo test

   cargo clippy

   cargo fmt --check

   ```

4. **Update Documentation**
   - Update README.md if adding new features
   - Add examples to module documentation
   - Update CHANGELOG.md

### Bug Fixes


1. **Reproduce the Issue**
   - Create a test that demonstrates the bug
   - Understand the root cause

2. **Implement Fix**
   - Make minimal changes to fix the issue
   - Ensure no regressions are introduced

3. **Verify Fix**
   - Ensure the test now passes
   - Run full test suite

### Documentation Improvements


1. **Identify Gaps**
   - Look for undocumented public APIs
   - Find examples that could be clearer
   - Check for outdated information

2. **Enhance Documentation**
   - Add missing documentation
   - Improve existing examples
   - Add troubleshooting guides

## 🧪 Testing Strategy


### Test Categories


1. **Unit Tests** (`cargo test unit_`)
   - Test individual functions
   - Mock external dependencies
   - Fast execution, no network

2. **Integration Tests** (`cargo test`)
   - Test against live Supabase
   - Require environment variables
   - Test complete workflows

3. **Performance Tests**
   - Benchmark query performance
   - Memory usage validation
   - Scalability testing

### Test Environment


Set up your test environment:

```env
# .env file for testing

SUPABASE_URL=https://your-test-project.supabase.co
SUPABASE_KEY=your-test-key
SUPABASE_RS_NO_NIGHTLY_MSG=true
```

### Writing Good Tests


```rust
#[tokio::test]

async fn test_insert_and_retrieve() -> Result<(), String> {
    let client = create_test_client();
    
    // Test data
    let test_user = json!({
        "name": "Test User",
        "email": "test@example.com"
    });
    
    // Insert
    let user_id = client.insert("users", test_user.clone()).await?;
    
    // Verify
    let users = client
        .select("users")
        .eq("id", &user_id)
        .execute()
        .await?;
    
    assert_eq!(users.len(), 1);
    assert_eq!(users[0]["name"], "Test User");
    
    // Cleanup
    client.delete("users", &user_id).await?;
    
    Ok(())
}
```

## 📋 Pull Request Process


### Before Submitting


1. **Check Requirements**
   - [ ] All tests pass (`cargo test`)
   - [ ] Code is formatted (`cargo fmt`)
   - [ ] No clippy warnings (`cargo clippy`)
   - [ ] Documentation is updated
   - [ ] CHANGELOG.md is updated (for features/fixes)

2. **Test Your Changes**
   ```bash
   # Run all checks

   cargo test

   cargo clippy -- -D warnings

   cargo fmt --check

   ```

### PR Guidelines


1. **Title**: Use clear, descriptive titles
   - `feat: add bulk insert functionality`
   - `fix: resolve connection timeout in select operations`
   - `docs: improve GraphQL examples and error handling`

2. **Description**: Include:
   - What changes were made
   - Why the changes were necessary
   - How to test the changes
   - Any breaking changes

3. **Size**: Keep PRs focused and reasonably sized
   - One feature or fix per PR
   - Split large changes into multiple PRs

### Review Process


1. **Automated Checks**: CI will run tests and linting
2. **Code Review**: Maintainers will review your changes
3. **Feedback**: Address any requested changes
4. **Merge**: Approved PRs will be merged by maintainers

## 🎯 Contribution Areas


### High-Priority Areas


1. **Core Functionality**
   - Improve query builder performance
   - Add missing CRUD operations
   - Enhance error handling

2. **Storage Operations**
   - Add file upload functionality
   - Implement streaming downloads
   - Add progress tracking

3. **GraphQL Stabilization**
   - Add mutation support
   - Implement subscription handling
   - Improve error reporting

4. **Documentation**
   - Add more comprehensive examples
   - Create tutorial guides
   - Improve API documentation

### Feature Requests


Before implementing new features:

1. **Check Issues**: Look for existing feature requests
2. **Discuss First**: Open an issue to discuss the feature
3. **Get Approval**: Wait for maintainer feedback
4. **Implement**: Follow the development process

## 🐛 Bug Reports


### Reporting Bugs


1. **Search First**: Check if the bug is already reported
2. **Provide Details**: Include:
   - Rust version
   - Crate version
   - Operating system
   - Minimal reproduction case
   - Expected vs actual behavior

3. **Use Template**: Follow the bug report template

### Bug Report Template


```markdown
**Bug Description**
A clear description of what the bug is.

**Reproduction Steps**
1. Initialize client with...
2. Call method...
3. Observe error...

**Expected Behavior**
What you expected to happen.

**Actual Behavior**
What actually happened.

**Environment**
- OS: [e.g., Ubuntu 22.04]
- Rust version: [e.g., 1.75.0]
- Crate version: [e.g., 0.4.14]
- Features enabled: [e.g., storage, rustls]

**Additional Context**
Any other relevant information.
```

## 📚 Resources


### Documentation


- [Rust API Guidelines]https://rust-lang.github.io/api-guidelines/
- [Supabase Documentation]https://supabase.io/docs
- [PostgREST API Reference]https://postgrest.org/en/stable/api.html

### Tools


- [rustfmt]https://github.com/rust-lang/rustfmt - Code formatting
- [clippy]https://github.com/rust-lang/rust-clippy - Linting
- [cargo-doc]https://doc.rust-lang.org/cargo/commands/cargo-doc.html - Documentation generation

## 🤝 Community


### Communication


- **GitHub Issues**: For bug reports and feature requests
- **GitHub Discussions**: For questions and general discussion
- **Pull Requests**: For code contributions

### Code of Conduct


- Be respectful and inclusive
- Focus on constructive feedback
- Help others learn and grow
- Follow Rust community standards

## 🏆 Recognition


Contributors are recognized in:
- README.md contributors section
- CHANGELOG.md for significant contributions
- GitHub contributor graphs

Thank you for contributing to `supabase_rs`! Your efforts help make Rust development with Supabase better for everyone.