Fork me on GitHub
#yada
<
2017-06-12
>
ikitommi04:06:13

Morning. The Spec & swagger - here’s one plan: * spec-tools is out and as stable as clojure.spec 😉 trying to get the separation of conforming & specs into clojure.spec itself - https://dev.clojure.org/jira/browse/CLJ-2116. * spec-swagger is ~70% done, we are trying to get it out before summer vacations (= in this month): first swagger2, later openapi3. Developed now as a separate repo and can be used as standalone - might end up into part of spec-tools. * ring-swagger is planned to get 1.0.0 rewrite with pluggable schema / spec / json schema / xyz, most likely after vacations * schema-tools will also get a facelift, targeting to make transition between schema & spec easy, similar way to add metadata to models, apply default values etc. some old thoughts on a gist: https://gist.github.com/ikitommi/fb3e0200504dd8b635ed7edd0cdbc768 yada-spec/swagger module should be easy as the apis are almost the same as with schema. and, everything can break with the next spec alpha..

mccraigmccraig09:06:19

@dominicm what does yada offer for graphql processing over just aleph ?

dominicm09:06:19

mccraigmccraig: Probably not much. I have no idea if yada could do some fancy encoding in the future though.

stijn11:06:53

not much indeed. I've created a graphql endoint based on the logic in https://github.com/walmartlabs/lacinia-pedestal

stijn11:06:19

i.e. a yada translation of that

dominicm14:06:42

We have that too 🙂. Might be one in edge too.

dominicm14:06:18

Yada at least provides content negotiation & such on top. And would allow for better caching too. graphql iirc does make caching harder though, so maybe nothing to do there.

wagjo12:06:14

Hey! Is there a way to update existing resource with some additional resource model map? For example, I'd like to enrich a resource created with (as-resource "some-url") with additional :access-control info.

wagjo13:06:05

OK I ended up doing (deep-merge (resource my-model) (as-resource "some-url")) Hope it's idiomatic 🙂

dominicm13:06:20

yeah, we do it all the time 🙂

borkdude14:06:24

@wagjo Yes, you can merge your own config in afterwards. It would be good to call yada/resource on that for additional validation.

borkdude14:06:12

(@wagjo there are already examples of this in our app)

wagjo14:06:58

thing is yada is doing a coercion from model map to the resource map, and this coercion is not done again if you assoc into a resource later. The above deep-merge works around that quite nicely

Rachel Westmacott14:06:28

“Since this week’s yada release manifold streams can be returned from response bodies.” I’m confused. I was previously returning a stream from a :response function with yada 1.2.4. Now I’m on 1.2.6 I find that I can’t: No implementation for render-seq for media-type: text/csv

Rachel Westmacott14:06:22

I guess I can provide an implementation for render-seq, but this change seems to be going in an unexpected direction.

Rachel Westmacott14:06:22

By providing an identity-like implementation for render-seq / "text/csv" it’s all working again, but I’m now wondering if I’m doing something I’m not supposed to…

dominicm15:06:19

@peterwestmacott sounds right. I have a feeling that something isn't being required.

Rachel Westmacott15:06:45

as in: there some ns I should require and then this would all work by itself?

dominicm15:06:27

@peterwestmacott maybe, I'd consider this a bug even if that's true!

dominicm15:06:09

Annoyingly, I can't find the string "text/csv" in history :thinking_face:

dominicm15:06:29

@peterwestmacott okay, figured it out j/k

dominicm15:06:33

We used to throw an exception, now we return an empty string. That's all I have.

dominicm15:06:45

No idea how that resulted in csvs working though 🙂

Rachel Westmacott15:06:49

Malcolm’s earlier comment about recently adding support for returning manifold streams seems to imply that I was going “off-piste” before then though.

dominicm15:06:05

Doesn't look like yada officially supports csvs

dominicm15:06:17

I've returned manifold streams before too, no idea what that commit is 😂

dominicm15:06:09

@peterwestmacott are you encoding the lines in the stream into a string line in the csv?

Rachel Westmacott15:06:24

I’m putting strings onto the stream

Rachel Westmacott15:06:38

each string contains comma separated fields

Rachel Westmacott15:06:04

each string ends in a newline character

Rachel Westmacott15:06:45

eg. (streams/put! stream "2017-01-01,some,data,here\n")

dominicm15:06:24

I see. I wonder if that change broke returning strings over a stream as being like returning a string from a response

Rachel Westmacott15:06:13

I would think that for some media types the answer is yes

Rachel Westmacott15:06:27

previously in yada.body/MessageBody they would have fallen through to Object, which returns the stream unaltered. Now they will have render-seq called on them which requires an implementation for the media-type

Rachel Westmacott15:06:53

which isn’t necessarily bad, in the sense that maybe I was doing something unsupported(?), and expecting every combination of media-type/return-type to be supported out of the box is unrealistic, and it is trivially extensible

dominicm15:06:15

I'd like to see yada/csv 😉