-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serialize function #20
Conversation
I think a good idea would be to enable serialization per a single IMO best option would be to add support for optional config for |
Is this the reverse of parse? This would actually be great to facilitate a correctly typed optimisticResponse. We need to serialize that before passing it to apollo. |
@jfrolich Thats exactly the idea. It will allow direct cache manipulation keeping all Reason/OCaml types like variants, etc. |
Ok. I will incorporate this in reason-apollo-hooks when this lands! |
Would it be technically possible to have the "pure JS" type along with the parsed response type (with We are discussing how to improve usage of apollo cache in @fakenickels came up with this idea here, would be really cool to know whether it is techincally possible to implement 😄 |
@MargaretKrutikova It shouldn't be a problem. We can add any additional fields to the query result. For me, it makes sense to do it only for The current plan is to provide |
Chiming in here (and had this comment over at
We use both @bsField and @bsDecoder in queries that we also need to serialise. Would this change make it impossible? Even having just the pure JS type of queries and mutations available (in addition to the parsed type of course) would be incredibly helpful for us - at least until a (better) solution has landed. |
@mbirkegaard I don't want to deprecate Having a pure JS type seems interesting. It probably could work similar to |
We use
(We use a module with some decoder helpers to build decoding pipelines, but that isn't really important here) The fragment is then used in other queries/types via We want to get to the point where we only define once per domain type (like price) how to ingest data from GraphQL and turn it into a type for the frontend. There's still a way to go, but it already looks pretty promising.
I must admit that I don't know how Or do you mean how I think unions and interfaces should be handled? Hmm... yeah. Need to think about that - I don't really have a good answer for that yet. Writing encoders, either for whole queries or with a Come to think of it, is this the right place for me to bring these things up? -- Seems it should be in an issue rather than on this PR. |
@mbirkegaard If you have suggestions and feature requests not directly related to this PR, please open an issue. As far as I understand your problem is lack of @bsDecoder on fragments for example, as it would simplify your workflow when handling e.g I think the best option would be to deprecate Still, not sure how to handle |
Will do! It started out being kinda related to this, but then I got carried away 😄 |
This shipped in another form in #101 (same functionality). |
Resolves: #20
This PR introduces opt-int
GRAPHQL_PPX_SERIALIZATION_EXPERIMENTAL=true
flag which addsfunction to the generated module. This feature is experimental and breaks some existing features because of it's limitations.
Limitations
@bsField
is not supported as it's only one way (adding new fields to query). Possible solution - maybe we can work around it by flattening the object, not sure about this.@bsDecoder
is not supported because it specifies only decode function. Possible solution: provide@bsDecoder(decodeFn: "", encodeFn: "")
Nonexhaustive
case. Possible solution - changeNonexhaustive
toNonexhaustive(typename, Js.t('a))