Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Replace `BiMap` with plain maps

Aberta
#861 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
45/100
Tipo de issue
Refatoração
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
java, kotlin

Direção de pesquisa

Start by tracing how SchemaClassScanner builds TypeClassDictionary and how SchemaParser uses it in both directions, including resolver return types. Then review SchemaParserDictionary.getDictionary() and the graphql-spring-boot call to builder.dictionary(); done means duplicate classes produce a SchemaClassScannerError naming the class and types, the new map-returning method is used without breaking the old API, and BiMap can be removed in a later major release.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

graphql.kickstart.tools.util.BiMap is a copy of Guava's BiMap we added when we dropped Guava (661769e). Neither Java nor Kotlin has a bidirectional map, so it stuck around. After #851 it doesn't really pull its weight anymore.

Where it's used:

  • SchemaClassScanner builds a BiMap<TypeDefinition, JavaType> (TypeClassDictionary). SchemaParser reads it both ways: dictionary[definition] for enum classes and dictionary.inverse() for InterfaceTypeResolver and UnionTypeResolver.
  • BiMap#put throwing value already present is the only thing that enforces one class per output type. It shows up as Error creating bimap of type => class, which isn't a very helpful message. It also catches classes found through resolver return types, not just dictionary entries, so a replacement needs an explicit check.
  • SchemaParserDictionary stores a plain map since #851. getDictionary() still returns a BiMap for backwards compatibility (graphql-spring-boot calls builder.dictionary(dictionary.getDictionary())), but its inverse() only keeps the first name when several input types share a class.

Proposal:

  1. Internally, use two plain maps plus an explicit duplicate check that throws a SchemaClassScannerError naming the class and the types. No API change.
typeToClass.entries.groupBy({ it.value }, { it.key })
    .filterValues { it.size > 1 }
    .forEach { (clazz, types) -> throw SchemaClassScannerError("...") }
val classToType = typeToClass.entries.associate { (type, clazz) -> clazz to type }
  1. Add a replacement for getDictionary() that returns Map<String, Class<*>> under a new name, and deprecate getDictionary(). Changing the return type in place would break binary compatibility.
  2. Switch graphql-spring-boot to the new method.
  3. Remove BiMap in the next major.
Linguagem predominante
Kotlin
Estrelas
824
Forks
175
Merge médio
2d 5h
PRs com merge (30d)
52

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de graphql-java-kickstart/graphql-java-tools

Todas as issues de graphql-java-kickstart/graphql-java-tools

Issues semelhantes

Mais issues de Kotlin

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.