pathom

Eric Dvorsak 2024-06-12T15:59:04.286369Z

The spec of pco/? seems to be wrong in com.wsscode.pathom3.connect.operation/??

(>defn ?
  "Make an attribute optional"
  [attr]
  [::p.attr/attribute => any?]
  (eql/update-property-param attr assoc ::optional? true))
where
(>def ::attribute keyword?)
but I expect
(pco/? {:user/subscription [:subscription/active?]})
to be allowed?

favila 2024-06-12T17:10:53.042109Z

The ? does need to surround :user/subscription

favila 2024-06-12T17:11:09.119369Z

It is implemented as an attribute parameter

Eric Dvorsak 2024-06-12T17:14:59.115109Z

Even if it has sub attributes?

favila 2024-06-12T17:18:44.374649Z

Yes. It is this EQL syntax: https://edn-query-language.org/eql/1.0.0/specification.html#_parameters

favila 2024-06-12T17:18:51.383459Z

Sorry didn't mean to send to channel

favila 2024-06-12T17:19:24.848239Z

The ? function is a wrapper around updating the attribute spec to include a parameter that specifies optionality

favila 2024-06-12T17:23:37.320599Z

Arguably the spec is still wrong because attribute could be something that already has a property param and the code would still work. e.g. {(pco/? '(:user/subscription {:my-param/limit 5})) [:subscription/active?]}

wilkerlucio 2024-06-12T17:26:08.605489Z

@favila you right, the spec for ::attribute is wrong (incomplete to be more accurate) in this case, given it could be a parameterized one already

favila 2024-06-12T17:27:44.260629Z

Spec maybe should be ::eql/join-key?

wilkerlucio 2024-06-12T17:28:34.022099Z

I'm just having a look to see what would be more appropriate, join-key is almost, but I dont wanna make idents valid

favila 2024-06-12T17:28:44.311169Z

or maybe just ::eql/property and ::eql/join-key-param-expr

wilkerlucio 2024-06-12T17:28:50.365739Z

yup

favila 2024-06-12T17:28:54.233139Z

not sure there's a spec for just the two of those

wilkerlucio 2024-06-12T17:29:05.076609Z

I think a new combination for that case is fine

wilkerlucio 2024-06-12T17:30:23.206729Z

join-key-param-expr also supports idents, so not using that this time

wilkerlucio 2024-06-12T17:31:49.941719Z

adding a few ones:

(>def ::attribute keyword?)
(>def ::parameterized-attribute (s/and seq? (s/cat :attr ::attribute :params (s/? ::params))))
(>def ::attribute-maybe-parameterized (s/or :plain-attr ::attribute :parameterized ::parameterized-attribute))

wilkerlucio 2024-06-12T17:31:54.162769Z

(in Pathom 3 context)

wilkerlucio 2024-06-12T17:32:17.031659Z

taking suggestions for better names if you have any, hehe

wilkerlucio 2024-06-12T17:32:30.843989Z

for the attribute-maybe-parameterized specially

wilkerlucio 2024-06-12T18:03:36.764529Z

https://github.com/wilkerlucio/pathom3/pull/213

👍 1
wilkerlucio 2024-06-13T13:28:43.379279Z

merged