Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Replace `BiMap` with plain maps

オープン
#861 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java, kotlin

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
Kotlin
スター
824
フォーク
175
平均マージ
2日 5時間
マージ済み PR(30日)
52

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

graphql-java-kickstart/graphql-java-tools のほかの issue

graphql-java-kickstart/graphql-java-tools の issue をすべて見る

似ている issue

Kotlin の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。