tendant / graphql-clj

A Clojure library that provides GraphQL implementation.
Eclipse Public License 1.0
285 stars 22 forks source link

Enable the use of spec backport for Clojure < 1.9.0 #32

Closed aew closed 7 years ago

aew commented 7 years ago

I've seen a number of different libraries that do not yet work with Clojure 1.9, so it seems premature to force this on the library user today given the use of spec.

Also, refactor spec namespace to consistently put node before state, as in the visitors / validators.

tendant commented 7 years ago

I was thinking about using clojure-spec backport for supporting Clojure before 1.9. To make it clean, we might need consider not to use namespace clojure.future. So that for project using Clojure 1.9.0, the clojure-spec-backport can be excluded easily.

Assume only validator will use clojure.spec. A few options I am thinking:

  1. Not use any function in clojure.future.

For project using Clojure< 1.9.0, if validator is used, clojure-spec-backport is required, if validator is not used, clojure-spec-backport is not required.

For project using Clojure 1.9.0, clojure-spec-backport can be excluded.

  1. Use functions in clojure.future

For all projects, clojure-spec-backport might be conflict with clojure.spec in 1.9.0

  1. Copy clojure.future into graphql-clj for supporting clojure-spec-backport, in such case, clojure-spec-backport can be excluded if needed.
xsc commented 7 years ago

I don't think such a backport belongs into libraries. Shouldn't it be something users with old Clojure versions include? E.g.:

:dependencies [[org.clojure/clojure "1.8.0"]
               [graphql-clj "0.1.17" :exclusions [org.clojure/clojure]]
               [clojure-spec-backport "1.9.0-alpha13"]]

Of course, the backport has to provide the namespace clojure.spec then, to seamlessly integrate with e.g. graphql-clj.

aew commented 7 years ago

I've updated this PR to reflect the comments. I replicated 3 functions from clojure.future in order to do this. To @xsc's point, library users can make this decision for themselves. I've added instructions to the readme for this.