Best practices for handling gqlgen resolvers with shared query metadata
- Lenguaje dominante
- Go
- Estrellas
- 10.8k
- Forks
- 1.3k
- Merge medio
- 2 d 36 min
- PR fusionados (30 d)
- 26
Descripción
Hi everyone,
I'm working with gqlgen and need advice on the best way to structure resolvers and gqlgen.yml for the following schema:
```
query {
request: QueryMessage!
}
type QueryMessage {
requestID: String!
offline: Boolean!
maxPageSize: Int
{{userType1}}(filter: {{UserTypeFilterInput1}}!, offset: Int, limit: Int, cursor: String): {{UserTypeResult1}}!
...
{{userTypeN}}(filter: {{UserTypeFilterInputN}}!, offset: Int, limit: Int, cursor: String): {{UserTypeResultN}}!
}
```
Each userType* field in QueryMessage needs access to requestID, offline, and maxPageSize. What is the best approach to achieve this in gqlgen?
How should I structure gqlgen.yml to properly generate resolvers for QueryMessage?
How can I ensure that each resolver function for userType* has access to requestID, offline, and maxPageSize?
Should QueryMessage be a custom Go struct, and if so, how should it be instantiated in resolvers?
Are there best practices for caching or sharing the QueryMessage context across multiple field resolvers?
Any guidance or examples would be greatly appreciated. Thanks!
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.