pathom 2024-06-12

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?

The ? does need to surround :user/subscription

It is implemented as an attribute parameter

Even if it has sub attributes?

Sorry didn't mean to send to channel

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

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?]}

@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

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

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

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

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

I think a new combination for that case is fine

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

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))

(in Pathom 3 context)

taking suggestions for better names if you have any, hehe

for the attribute-maybe-parameterized specially