99designs / 99designs/gqlgen

Best practices for handling gqlgen resolvers with shared query metadata

Abierto
#3,607 0 comentarios 0 reacciones 0 asignados Ver en GitHub
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

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.