Not possible to discern GraphQL scalar unmarshal errors in error presenter
- Linguagem predominante
- Go
- Estrelas
- 10.8k
- Forks
- 1.3k
- Merge médio
- 2d 36min
- PRs com merge (30d)
- 26
Descrição
### What happened?
Errors occurring in packaged scalars like `Int` return unstructured `error`s making them difficult to identify in an [error presenter](https://gqlgen.com/reference/errors/#the-error-presenter).
See https://github.com/99designs/gqlgen/blob/414a4d3414b2b5856851816f0152980098f7b3ab/graphql/int.go#L16-L29 for example.
In our case, we catch any top level `error`s that are not one of our expected types to ensure we don't leak internal information to the API due to neglecting to wrap an error. However, I don't see an easy way to catch these errors aside from implementing our own unmarshaling functions.
### What did you expect?
I'm curious if it would make sense to return `gqlerror.Error`s in the `Unmarshal*` scalar methods so that an error presenter could identify that these errors are safe to pass back to the client.
Alternatively, perhaps they could return a new error type like `gqlerror.UnmarshalError`.
### versions
- gqlversion 0.9.0
- go version 1.12.6
Guia de contribuição
Direção de pesquisa
Examine as funções de unmarshaling de escalares na base de código do gqlgen, como graphql/int.go. Entenda como os erros são retornados atualmente e como o error presenter funciona. O objetivo é modificar essas funções para que retornem um gqlerror.Error ou um novo tipo de erro identificável, garantindo que o error presenter possa distingui-los. Verifique os testes existentes para unmarshaling de escalares a fim de conferir o comportamento esperado e adicione testes para o novo tratamento de erros.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- go, graphql
- Domínio
- api, backend-api-design
- Tipo de issue
- Funcionalidade
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 45/100