Skip to content

Commit

Permalink
Restrict values inside ListValue and ObjectValue (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmoraunio authored Jun 7, 2024
1 parent 9c91edc commit 54c7c5c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/oksa/parse.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@
(or (re-matches re-variable-reference s)
(re-matches re-enum-value s))))]]
:keyword)
coll?
:map]
[:sequential [:ref ::Value]]
[:map-of [:ref ::Name] [:ref ::Value]]]
::Arguments [:map-of [:ref ::Name] [:ref ::Value]]
::Directives [:orn [::Directives [:+ [:orn
[::DirectiveName [:schema [:ref ::DirectiveName]]]
Expand Down
4 changes: 3 additions & 1 deletion test/oksa/alpha/api_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@
(unparse-and-validate (api/select (api/field :fooField (api/opts (api/arguments :foo "\\")))))))
(t/is (= "{fooField(foo:\"foo\\b\\f\\r\\n\\tbar\")}"
(unparse-and-validate (api/select (api/field :fooField (api/opts (api/argument :foo "foo\b\f\r\n\tbar")))))
(unparse-and-validate (api/select (api/field :fooField (api/opts (api/arguments :foo "foo\b\f\r\n\tbar"))))))))))
(unparse-and-validate (api/select (api/field :fooField (api/opts (api/arguments :foo "foo\b\f\r\n\tbar"))))))))
(t/is (thrown-with-msg? #?(:clj Exception :cljs js/Error) #"invalid arguments"
(api/arguments :foo #uuid"5bc915e9-1a9a-4780-8cf9-16aae80ec3fc")))))
(t/testing "document"
(t/is (= "{foo}"
(unparse-and-validate (api/document (api/select :foo)))))
Expand Down
5 changes: 4 additions & 1 deletion test/oksa/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@
(t/is (= "{fooField(foo:\"\\\\\")}"
(unparse-and-validate [[:fooField {:arguments {:foo "\\"}}]])))
(t/is (= "{fooField(foo:\"foo\\b\\f\\r\\n\\tbar\")}"
(unparse-and-validate [[:fooField {:arguments {:foo (str "foo\b\f\r\n\tbar")}}]]))))))
(unparse-and-validate [[:fooField {:arguments {:foo (str "foo\b\f\r\n\tbar")}}]]))))
(t/is (thrown-with-msg? #?(:clj Exception :cljs js/Error) #"invalid form"
(unparse-and-validate [[:foo {:arguments {:foo #uuid"5bc915e9-1a9a-4780-8cf9-16aae80ec3fc"}}
[:bar]]])))))
(t/testing "document"
(t/is (= "{foo}"
(unparse-and-validate [:<> [:foo]])
Expand Down

0 comments on commit 54c7c5c

Please sign in to comment.