Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
ac93eacbbc
|
|||
| e96ce57940 | |||
| 923e6a5585 | |||
| b2617b1eb2 | |||
| 023d0ed776 | |||
| f7c85d1e56 | |||
| f6632726c5 | |||
| 1d58e4afb1 | |||
| 1b7274b421 | |||
| e7bea420a7 | |||
| 14b00f06d3 | |||
| b286d56403 | |||
| 5c1b8981d1 | |||
| 9bb84fb008 | |||
| a3c4bcfe0f | |||
| 6deb62064d | |||
| eb8cefdc83 |
@@ -1,2 +1,3 @@
|
|||||||
.idea
|
.idea
|
||||||
|
.claude
|
||||||
/release
|
/release
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@ include:
|
|||||||
- project: unboundsoftware/ci-templates
|
- project: unboundsoftware/ci-templates
|
||||||
file: Pre-Commit-Go.gitlab-ci.yml
|
file: Pre-Commit-Go.gitlab-ci.yml
|
||||||
|
|
||||||
image: amd64/golang:1.25.4@sha256:efe81fa41fdf81fb873ab7cd931b9bb29bd10aced6c252cbd91739c34e654f01
|
image: amd64/golang:1.25.5@sha256:ad03ba93327b8a6143b49373790b5d92c28067bdb814418509466122ee9c9e63
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- deps
|
- deps
|
||||||
@@ -32,7 +32,7 @@ test:
|
|||||||
|
|
||||||
vulnerabilities:
|
vulnerabilities:
|
||||||
stage: test
|
stage: test
|
||||||
image: amd64/golang:1.25.4@sha256:efe81fa41fdf81fb873ab7cd931b9bb29bd10aced6c252cbd91739c34e654f01
|
image: amd64/golang:1.25.5@sha256:ad03ba93327b8a6143b49373790b5d92c28067bdb814418509466122ee9c9e63
|
||||||
script:
|
script:
|
||||||
- go install golang.org/x/vuln/cmd/govulncheck@latest
|
- go install golang.org/x/vuln/cmd/govulncheck@latest
|
||||||
- govulncheck ./...
|
- govulncheck ./...
|
||||||
|
|||||||
@@ -37,10 +37,10 @@ repos:
|
|||||||
- id: go-test
|
- id: go-test
|
||||||
- id: gofumpt
|
- id: gofumpt
|
||||||
- repo: https://github.com/golangci/golangci-lint
|
- repo: https://github.com/golangci/golangci-lint
|
||||||
rev: v2.6.2
|
rev: v2.7.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: golangci-lint-full
|
- id: golangci-lint-full
|
||||||
- repo: https://github.com/gitleaks/gitleaks
|
- repo: https://github.com/gitleaks/gitleaks
|
||||||
rev: v8.29.1
|
rev: v8.30.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: gitleaks
|
- id: gitleaks
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# presenter
|
||||||
|
|
||||||
|
Shared Go library for GraphQL error presentation with coded errors.
|
||||||
|
|
||||||
|
## Shared Documentation
|
||||||
|
|
||||||
|
@../docs/claude/architecture.md
|
||||||
|
@../docs/claude/go-services.md
|
||||||
|
@../docs/claude/graphql.md
|
||||||
|
@../docs/claude/conventions.md
|
||||||
|
|
||||||
|
## Library Information
|
||||||
|
|
||||||
|
### Purpose
|
||||||
|
|
||||||
|
Provides a standardized GraphQL error presenter that handles coded errors across all microservices. Converts internal error codes to GraphQL error extensions.
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
|
||||||
|
```go
|
||||||
|
import "gitlab.com/unboundsoftware/shiny/presenter"
|
||||||
|
|
||||||
|
// Create error presenter with valid codes and entities
|
||||||
|
errorPresenter := presenter.New(logger, validCodes, validEntities, internalErrorCode)
|
||||||
|
|
||||||
|
// Use in gqlgen server config
|
||||||
|
srv := handler.NewDefaultServer(generated.NewExecutableSchema(cfg))
|
||||||
|
srv.SetErrorPresenter(errorPresenter)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Key Types
|
||||||
|
|
||||||
|
- `CodedError` - Error type with code, entity, and params
|
||||||
|
- `Code` - Error code type
|
||||||
|
- `Entity` - Error entity type
|
||||||
|
|
||||||
|
### Error Extensions
|
||||||
|
|
||||||
|
Errors are presented with extensions:
|
||||||
|
- `code` - The error code (mapped to valid codes or internal error)
|
||||||
|
- `errorEntity` - The entity related to the error (optional)
|
||||||
|
- `params` - Additional error parameters (optional)
|
||||||
@@ -3,7 +3,7 @@ module gitlab.com/unboundsoftware/shiny/presenter
|
|||||||
go 1.24.1
|
go 1.24.1
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/99designs/gqlgen v0.17.84
|
github.com/99designs/gqlgen v0.17.85
|
||||||
github.com/stretchr/testify v1.11.1
|
github.com/stretchr/testify v1.11.1
|
||||||
github.com/vektah/gqlparser/v2 v2.5.31
|
github.com/vektah/gqlparser/v2 v2.5.31
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
github.com/99designs/gqlgen v0.17.84 h1:iVMdiStgUVx/BFkMb0J5GAXlqfqtQ7bqMCYK6v52kQ0=
|
github.com/99designs/gqlgen v0.17.85 h1:EkGx3U2FDcxQm8YDLQSpXIAVmpDyZ3IcBMOJi2nH1S0=
|
||||||
github.com/99designs/gqlgen v0.17.84/go.mod h1:qjoUqzTeiejdo+bwUg8unqSpeYG42XrcrQboGIezmFA=
|
github.com/99designs/gqlgen v0.17.85/go.mod h1:yvs8s0bkQlRfqg03YXr3eR4OQUowVhODT/tHzCXnbOU=
|
||||||
github.com/agnivade/levenshtein v1.2.1 h1:EHBY3UOn1gwdy/VbFwgo4cxecRznFk7fKWN1KOX7eoM=
|
github.com/agnivade/levenshtein v1.2.1 h1:EHBY3UOn1gwdy/VbFwgo4cxecRznFk7fKWN1KOX7eoM=
|
||||||
github.com/agnivade/levenshtein v1.2.1/go.mod h1:QVVI16kDrtSuwcpd0p1+xMC6Z/VfhtCyDIjcwga4/DU=
|
github.com/agnivade/levenshtein v1.2.1/go.mod h1:QVVI16kDrtSuwcpd0p1+xMC6Z/VfhtCyDIjcwga4/DU=
|
||||||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
|
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
|
||||||
|
|||||||
Reference in New Issue
Block a user