Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Replace `BiMap` with plain maps

Ouverte
#861 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
45/100
Type d'issue
Refactorisation
Clarté
Plutôt claire
Activité
Active
Stack technique
java, kotlin

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.
Langage dominant
Kotlin
Étoiles
824
Forks
175
Merge moyen
2 j 5 h
PR mergées (30 j)
52

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de graphql-java-kickstart/graphql-java-tools

Toutes les issues de graphql-java-kickstart/graphql-java-tools

Issues similaires

Plus d'issues Kotlin

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.