(might be a super-noob question, sorry, I have no ...
# prisma-whats-new
p
(might be a super-noob question, sorry, I have no idea what I’m talking about, but I know why I’m asking :D)
n
@picosam that's correct! We are looking to offer the ability to build custom resolvers with a feature we call "custom mutations/queries" (https://github.com/graphcool/feature-requests/issues/40). However, with functions you can already achieve pretty advanced use cases. What exactly do you want to do?
p
My famous flattening-of-the-single-item-array optimization 😄
This would happen on reading though (query) not on mutations
n
Ah I see
you have a
to-many
relation, right? why not change it to a
to-one
?
p
Because I store languages, so it has to be a to-many
I just filter according to the user language when I do the query
n
Ahh I see
and also, why don't you like the naïve approach? Do the transformation logic on the client after receiving the data
another option is to transform the data before it is injected into the component: http://dev.apollodata.com/react/queries.html#graphql-props-option
p
Hmm… I’m using angular, but yes, let me check this out.
n
oh, right. the afterware is also available for Angular because it's part of
apollo-client
itself
👍 1
p
About doing the mapping, it gets a bit complicated quite quickly actually
n
hm I have no experience with
afterware
it might be completely wrong
🙂
p
LOL; hey, be careful, I take your advice seriously!
n
Well, it gives you the ability to look into the actual response
and transform it
but it might be the wrong "abstraction level"
I think the way to transform it with React is probably the best approach and it should also be available with Angular.
p
Yeah so that’s using RxJs mapping, which is what I’m doing now… except it really got complicated very quickly
n
😕
p
But hey, I’ll keep going down that road…
a
The result.response.json() contains the query result in applyAfterware, so you can use that to perform the flattening. If necessary, you can use the helpers to turn it into a GraphQL document for easy parsing, but I can't find that example right now...