Skip to content

Commit 25dbdec

Browse files
authored
Export functionality for CSV and Excel (#574)
support for export functionality for databases except redis (future work). need to figure out the best format for elasticsearch/mongodb going forward
1 parent 2d0f895 commit 25dbdec

File tree

36 files changed

+1727
-218
lines changed

36 files changed

+1727
-218
lines changed

BUILD_AND_RUN.md

Lines changed: 151 additions & 168 deletions
Large diffs are not rendered by default.

CLAUDE.md

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ npm run cypress:ee # EE tests
4141

4242
### GraphQL Code Generation
4343
```bash
44-
# Backend (from core/)
45-
go run github.com/99designs/gqlgen generate
44+
# Backend CE (from core/)
45+
go generate ./...
46+
47+
# Backend EE (from core/)
48+
GOWORK=../go.work.ee go generate ./...
4649

4750
# Frontend (from frontend/)
4851
npm run generate # Generates TypeScript types from GraphQL
@@ -117,4 +120,41 @@ WhoDB is a database management tool with a **dual-edition architecture**:
117120
5. **Docker Development**
118121
- Multi-stage build optimizes image size
119122
- Supports AMD64
120-
- Uses Alpine Linux for minimal runtime
123+
- Uses Alpine Linux for minimal runtime
124+
125+
## GraphQL First Architecture
126+
127+
### Important: GraphQL is the Default API
128+
- **Always use GraphQL** for new API endpoints unless explicitly instructed otherwise
129+
- **Do NOT modify or add HTTP resolvers** in `http.resolvers.go` unless specifically requested
130+
- The codebase follows a GraphQL-first approach for all data operations
131+
132+
### GraphQL Implementation Pattern
133+
1. **GraphQL queries are NOT created with inline strings**
134+
2. **Proper GraphQL workflow**:
135+
- Create `.graphql` files in the appropriate frontend directory (e.g., `src/pages/[feature]/query-name.graphql`)
136+
- Run `pnpm run generate` (with the backend running) to generate TypeScript types and hooks
137+
- Import the generated documents from `@graphql` alias
138+
- Use the generated hooks with Apollo Client
139+
140+
### Example of Correct GraphQL Usage
141+
```typescript
142+
// WRONG - Do not do this:
143+
const QUERY = gql`query MyQuery { ... }`;
144+
145+
// CORRECT - Do this instead:
146+
// 1. Create file: src/pages/feature/my-query.graphql
147+
// 2. Run: pnpm run generate
148+
// 3. Import and use:
149+
import { useMyQuery } from '@graphql';
150+
```
151+
152+
### Backend GraphQL Development
153+
- Add new queries/mutations to `core/graph/schema.graphqls`
154+
- Implement resolvers in appropriate resolver files (e.g., `core/graph/model.resolvers.go`)
155+
- HTTP endpoints should only be used for special cases like file downloads that can't be handled via GraphQL
156+
157+
## Running GraphQL Code Generation
158+
1. Ensure the backend is running: `cd core && go run .`
159+
2. Run code generation: `cd frontend && pnpm run generate`
160+
3. This will update `src/generated/graphql.tsx` with all types and hooks

core/go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ require (
1616
github.com/pkg/errors v0.9.1
1717
github.com/sirupsen/logrus v1.9.3
1818
github.com/vektah/gqlparser/v2 v2.5.28
19+
github.com/xuri/excelize/v2 v2.9.1
1920
go.mongodb.org/mongo-driver v1.17.3
2021
gorm.io/driver/clickhouse v0.7.0
2122
gorm.io/driver/mysql v1.5.7
@@ -53,22 +54,28 @@ require (
5354
github.com/montanaflynn/stats v0.7.1 // indirect
5455
github.com/paulmach/orb v0.11.1 // indirect
5556
github.com/pierrec/lz4/v4 v4.1.22 // indirect
57+
github.com/richardlehane/mscfb v1.0.4 // indirect
58+
github.com/richardlehane/msoleps v1.0.4 // indirect
5659
github.com/russross/blackfriday/v2 v2.1.0 // indirect
5760
github.com/segmentio/asm v1.2.0 // indirect
5861
github.com/shopspring/decimal v1.4.0 // indirect
5962
github.com/sosodev/duration v1.3.1 // indirect
63+
github.com/tiendc/go-deepcopy v1.6.0 // indirect
6064
github.com/urfave/cli/v2 v2.27.6 // indirect
6165
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
6266
github.com/xdg-go/scram v1.1.2 // indirect
6367
github.com/xdg-go/stringprep v1.0.4 // indirect
6468
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
69+
github.com/xuri/efp v0.0.1 // indirect
70+
github.com/xuri/nfp v0.0.1 // indirect
6571
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
6672
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
6773
go.opentelemetry.io/otel v1.36.0 // indirect
6874
go.opentelemetry.io/otel/metric v1.36.0 // indirect
6975
go.opentelemetry.io/otel/trace v1.36.0 // indirect
7076
golang.org/x/crypto v0.38.0 // indirect
7177
golang.org/x/mod v0.24.0 // indirect
78+
golang.org/x/net v0.40.0 // indirect
7279
golang.org/x/sync v0.14.0 // indirect
7380
golang.org/x/sys v0.33.0 // indirect
7481
golang.org/x/text v0.25.0 // indirect

core/go.sum

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
118118
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
119119
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
120120
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
121+
github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM=
122+
github.com/richardlehane/mscfb v1.0.4/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk=
123+
github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
124+
github.com/richardlehane/msoleps v1.0.4 h1:WuESlvhX3gH2IHcd8UqyCuFY5yiq/GR/yqaSM/9/g00=
125+
github.com/richardlehane/msoleps v1.0.4/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
121126
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
122127
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
123128
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
@@ -139,6 +144,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
139144
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
140145
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
141146
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
147+
github.com/tiendc/go-deepcopy v1.6.0 h1:0UtfV/imoCwlLxVsyfUd4hNHnB3drXsfle+wzSCA5Wo=
148+
github.com/tiendc/go-deepcopy v1.6.0/go.mod h1:toXoeQoUqXOOS/X4sKuiAoSk6elIdqc0pN7MTgOOo2I=
142149
github.com/urfave/cli/v2 v2.27.6 h1:VdRdS98FNhKZ8/Az8B7MTyGQmpIr36O1EHybx/LaZ4g=
143150
github.com/urfave/cli/v2 v2.27.6/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
144151
github.com/vektah/gqlparser/v2 v2.5.28 h1:bIulcl3LF69ba6EiZVGD88y4MkM+Jxrf3P2MX8xLRkY=
@@ -153,6 +160,12 @@ github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6
153160
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
154161
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
155162
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
163+
github.com/xuri/efp v0.0.1 h1:fws5Rv3myXyYni8uwj2qKjVaRP30PdjeYe2Y6FDsCL8=
164+
github.com/xuri/efp v0.0.1/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
165+
github.com/xuri/excelize/v2 v2.9.1 h1:VdSGk+rraGmgLHGFaGG9/9IWu1nj4ufjJ7uwMDtj8Qw=
166+
github.com/xuri/excelize/v2 v2.9.1/go.mod h1:x7L6pKz2dvo9ejrRuD8Lnl98z4JLt0TGAwjhW+EiP8s=
167+
github.com/xuri/nfp v0.0.1 h1:MDamSGatIvp8uOmDP8FnmjuQpu90NzdJxo7242ANR9Q=
168+
github.com/xuri/nfp v0.0.1/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
156169
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
157170
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
158171
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
@@ -181,6 +194,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
181194
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
182195
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
183196
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
197+
golang.org/x/image v0.25.0 h1:Y6uW6rH1y5y/LK1J8BPWZtr6yZ7hrsy6hFrXjgsc2fQ=
198+
golang.org/x/image v0.25.0/go.mod h1:tCAmOEGthTtkalusGp1g3xa2gke8J6c2N565dTyl9Rs=
184199
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
185200
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
186201
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=

0 commit comments

Comments
 (0)