obmarg / cynic

A bring your own types GraphQL client library for Rust
https://cynic-rs.dev
Mozilla Public License 2.0
371 stars 46 forks source link

Parsing extensions contained in response #1016

Open matteofoccoli opened 2 weeks ago

matteofoccoli commented 2 weeks ago

Hello, my understanding is that at the moment, the GraphQlResponse grants access to data and errors. In our use case we're calling an external provider (Braintree) that provides also an extensions object in the response (here is their documentation).

Would it be possible to access that field in the response? We were able to parse extensions contained in the errors but not if they are contained in the response itself...

obmarg commented 2 weeks ago

Hi @matteofoccoli - thanks for the report. This is something cynic probably should support, but you're correct - at the moment it does not. Unfortunately I might need to make a breaking change to fix this, since the obvious fix would be adding another generic parameter into GraphQlResponse.

I am planning a major release sometime soon, so I may need to fix this as part of that - though I can't say exactly when that'll be.

In the meantime you can probably get at this field by using your own GraphQlResponse and integrating that with the http client library of your choice. I appreciate that it's not ideal but it shouldn't be too much code - the http & response modules in cynic are relatively simple and you probably only need a subset of them.