Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom type map #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add custom type map #5

wants to merge 1 commit into from

Conversation

p14n
Copy link

@p14n p14n commented Apr 10, 2019

Added custom type map by passing in opts as second param to schema (i.e. {:custom-type-map {"DateTime" 'DateTime}} )

…e {:custom-type-map {"DateTime" 'DateTime}} )
@luchiniatwork
Copy link
Collaborator

Hey @p14n ... this seems to be a feature that is clearly missing.

What do you think of something similar to the approach that was taken on the Datomic interface? See https://github.com/hodur-org/hodur-datomic-schema#scalar-types-and-finer-grained-control

@tothda
Copy link

tothda commented Oct 2, 2020

Hey @luchiniatwork !

I also need custom scalar support. I could work on this feature if we can agree on the interface.

How about this?

  (deftest test-custom-scalars
           (let [s (schema->lacinia '[^{:lacinia/tag true}
                                      default

                                      ^{:lacinia/scalar true
                                        :lacinia/parse :date-time-parser
                                        :lacinia/serialize :date-time-serializer}
                                      DateTime []

                                      Person
                                      [^ID id
                                       ^DateTime dob]])]

             (is (= '{:scalars
                      {:DateTime
                       {:parse :date-time-parser
                        :serialize :date-time-serializer}}
                      :objects
                      {:Person
                       {:fields
                        {:id {:type (non-null ID)}
                         :dob {:type (non-null :DateTime)}}}
                       }
                      }
                    s))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants