Vincit/venia

Add support for selecting types (inline fragments)

Opened this issue · 2 comments

I don't think it is possible to render the ... on Droid part of this query using what exists today.

query HeroForEpisode($ep: Episode!) {
  hero(episode: $ep) {
    name
    ... on Droid {
      primaryFunction
    }
  }
}

If I can, tell me how and I'll update the documentation if needed :-)

As far as I can tell, this feature is not implemented. You can use this ugly hack though

(defn inline-fragment
  [type fields]
  [(keyword (str "... on " (name type))) fields])

(comment

  (require '[venia.core :as venia])

  (venia/graphql-query {:venia/queries [[:hero {:episode :A_NEW_HOPE}
                                         [:name
                                          (inline-fragment :Droid [:primaryFunction])]]]})

  ;=> "{hero(episode:A_NEW_HOPE){name,... on Droid{primaryFunction}}}"

  )
err commented

desired helper made available via fc786c9 on #42