Skip to content

1.0.0

Compare
Choose a tag to compare
@ilmoraunio ilmoraunio released this 24 May 14:11
· 27 commits to main since this release
f08a425

1.0.0 (2024-05-24)

  • Adds support for name transformers #10
    • You can provide a custom function to transform names, fields, enums,
      directives, and types. See README for
      examples.
    • With this change, both the data DSL and API now uses the same unparser
      implementation under the hood.
  • Fixes parser bug with sequential selection sets #9
  • Adds babashka support #11

Name transformation

Supports top-level definitions and local overrides for transformers.

; clj -Sdeps '{:deps {fi.metosin/oksa {:mvn/version "1.0.0"} camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.3"}}}'

(require '[oksa.core :as o])
(require '[camel-snake-kebab.core :as csk])

(o/gql* {:oksa/name-fn csk/->camelCase
         :oksa/directive-fn csk/->snake_case
         :oksa/enum-fn csk/->SCREAMING_SNAKE_CASE
         :oksa/field-fn csk/->Camel_Snake_Case
         :oksa/type-fn csk/->PascalCase}
  [[:foo-bar {:alias :bar-foo
              :oksa/name-fn csk/->SCREAMING_SNAKE_CASE
              :directives [:foo-bar]
              :arguments {:foo-arg :bar-value}}
    [:foo-bar]]
   :naked-foo-bar
   [:...
    [:foo-bar]]
   [:... {:on :foo-bar-fragment
          :directives [:foo-bar]}
    [:foo-bar]]])

; => "{BAR_FOO:Foo_Bar(FOO_ARG:BAR_VALUE)@foo_bar{Foo_Bar} Naked_Foo_Bar ...{Foo_Bar} ...on fooBarFragment@foo_bar{Foo_Bar}}"