Generate interfaces for schema types defined in schema in kotlin projects
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 30/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- graphql, kotlin
- Área
- backend-api-design, tooling
Línea de trabajo
Comienza rastreando las tareas generateInterfaces y generateJava para proyectos de Kotlin, y revisa el issue relacionado #200 para consultar el contexto previo. Se considera terminado cuando los proyectos de Kotlin puedan generar interfaces para tipos definidos por el esquema mediante generateInterfaces, con el comportamiento verificado mediante pruebas adecuadas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
When I'm trying to generateInterfaces for kotlin language with use of generateJava task, they are not generated.
I saw ticket here that touch on this topic and it was stated that it is probably a feature of not a first priority.
I could probably add some context to highlight that this is pretty vital thing to have in kotlin based projects.
Let's take a look at the following setup:
type Team {
id: Int
parentTeam: Team!
childTeams: [Team!]!
}
Now I'm trying to organize my dataloaders and data fetchers as optimal as possible.
In kotlin projects I have the following options and none of them looks optimal to me:
-
Option 1: manually create interface for your types (not optimal from contract/schema perspective)
- Create
ITeaminterface:
interface ITeam { id: Int parentTeam: Team childTeams: [Team!]! } type Team implemets ITeam { id: Int parentTeam: ITeam! childTeams: [Team!]! }Then data fetcher will be something like this:
@DgsData fun fetchParentTeam( dfe: DgsDataFetchingEnvironment ): CompletableFuture<Team> { val parentTeamId = dfe.getSource<Team>()?.parentTeam?.id return parentTeamId?.let { val loader: DataLoader<Long, Team> = dfe.getDataLoader(TeamDataLoader::class.java) loader.load(it) } }In case of relational database on
val parentTeamId = dfe.getSource<Team>()?.parentTeam?.idline I have access to parent team id since it is...toOnerelation and I don't need additional db queries to find it out.Also in data loader I do this:
@DgsDataLoader class TeamDataLoader( private val teamService: TeamService, private val gqlDtoBuilder: GQLDtoBuilder ) : MappedBatchLoader<Long, Team?> { override fun load(keys: MutableSet<Long>): CompletionStage<Map<Long, Team?>> { return CompletableFuture.supplyAsync { val results = teamService .getTeamsByIds(keys) .associate { it.id to gqlDtoBuilder.build(it) } .toMutableMap<Long, Team?>() for (key in keys) { results.putIfAbsent(key, null) } results } } }Looks good so far but the query for such a schema is not that concise as it could be:
teams { parentTeam { id ... on Team { parentTeam // etc. } } }From client perspective it looks weird and doesn't feel right when performance backend stuff affects contract with external clients (another backend services, frontend, etc)
- Create
-
Option 2: not optimal from support perspective. We can use local context and it is good all in all but in a long team it looks a bit error prone since every time we do a fetch of
Teamtype we need to remember to pass local context in all data/entity fetchers. If we don't do that we got an error. Moreover if we get an additional field in schema liketeamLeadwe need to populate it everywhere we populate local context.
If project's graphql contract is not 100% covered with tests it could lead to errors on test/prod environments and with graphql request variety it is pretty difficult to keep test coverage on these high levels. -
Option 3: not optimal from performance perspective. We can fetch
parentTeamwith use of separate join db query and separate data loader logic but it is obviously not that fast and produces extra load on microservice itself and database. -
Option 4: looks promising, but has some java<->kotlin interop issues. In this cause we have the same interfaces like in option 1 but clients don't see them and we can extend them the way we like and use to carry info required by fetchers.
-
Option 5: ideal option. Have interfaces generated for kotlin projects too. The same as option 4, but java<->kotlin interop boilerplate is not there.
Could you please share if there any plans to make generateInterfaces available for kotlin?
Thank you very much!
- Lenguaje dominante
- Kotlin
- Estrellas
- 220
- Forks
- 123
- Merge medio
- 1 d 6 h
- PR fusionados (30 d)
- 23
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Netflix/dgs-codegen
-
Integer default values on `Float` input fields generate code that does not compile (Java and Kotlin)Posiblemente ocupada @0z5a la tomó hace 9 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
Netflix/dgs-codegen#1015 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 45/100
Netflix/dgs-codegen#1002 ·
Los mantenedores suelen responder en 1 día
-
Object literal default value on a custom scalar fails with NoSuchElementExceptionPosiblemente ocupada @nboisnea la tomó hace 49 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Netflix/dgs-codegen#982 ·
Los mantenedores suelen responder en 1 día
-
HV000271: Using @Valid on a container (java.util.List) is deprecated. You should apply the annotation on the type argument(s).Posiblemente ocupada @jiholee17 la tomó hace 72 días. Abiertoenhancement
Netflix/dgs-codegen#954 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Support Immutable java Data TypesQuizá libre de nuevo @jiholee17 la tomó hace 184 días y no hay ningún pull request abierto. Abiertoenhancement
Netflix/dgs-codegen#944 · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de Netflix/dgs-codegen
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 2 días
-
help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
DojoCodingLabs/hermit#23 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
signalapp/Signal-Android#15148 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
PranshulGG/WeatherMaster#1266 · 3 comentarios ·
Los mantenedores suelen responder en 1 día