Tensegritics / Tensegritics/ClojureDart

Getting member of HashMap using keyword returns null on Flutter Web

Open
#121 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Clojure
Stars
1.6k
Forks
119
PR merge metrics
No merged PRs in 30d

Description

Description

Getting member of HashMap using keyword returns null on Flutter Web but runs ok on mobile. This problem I got when getting data from an API using GraphQL.

https://clojurians.slack.com/archives/C03A6GE8D32/p1656243161601779

Reproducable Code

(defn- keywordize-blunt
  "Make keys of map turn to keyword"
  [entry]
  (cond
    (dart/is? entry Map)
    (loop [result {}
           entries (seq entry)]
      (let [[k v] (first entries)]
        (if k
          (recur
           (assoc result
                  (keyword k)
                  (keywordize-blunt v))
           (rest entries))
          result)))

    (dart/is? entry List)
    (map (fn [e] (keywordize-blunt e)) entry)

    :else entry))

(let [r {"__typename" "Query"
             "organizationLoyaltyMessageRandomMessage"
             {"__typename" "OrganizationLoyaltyMessage"
              "pictureUrl" nil
              "message" "\"Kamu tidak perlu menjadi luar biasa untuk memulai, tapi kamu harus memulai untuk menjadi luar biasa.\" – Zig Ziglar"}}
        rk (keywordize-blunt r)]
      (dart:core/print (get r "organizationLoyaltyMessageRandomMessage"))
      (dart:core/print rk)
      (dart:core/print (:organizationLoyaltyMessageRandomMessage rk)))

log

{"pictureUrl" nil, "__typename" "OrganizationLoyaltyMessage", "message" "\"Kamu tidak perlu menjadi luar biasa untuk memulai, tapi kamu harus memulai untuk menjadi luar biasa.\" – Zig Ziglar"}

{:__typename "Query", :organizationLoyaltyMessageRandomMessage {:pictureUrl nil, :__typename "OrganizationLoyaltyMessage", :message "\"Kamu tidak perlu menjadi luar biasa untuk memulai, tapi
kamu harus memulai untuk menjadi luar biasa.\" – Zig Ziglar"}}

null

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproducible ClojureDart snippet and compare its HashMap keyword lookup on Flutter Web with the reported mobile behavior. Investigate the difference using the GraphQL-shaped nested data shown in the example. Done means the final keyword lookup returns the nested value on Flutter Web instead of null, with the behavior verified by a regression check.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure, dart, flutter, graphql
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.