Skip to content
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

GraphQlResponse Clonable? #810

Closed
AlexandreRoba opened this issue Jan 8, 2024 · 4 comments · Fixed by #811
Closed

GraphQlResponse Clonable? #810

AlexandreRoba opened this issue Jan 8, 2024 · 4 comments · Fixed by #811

Comments

@AlexandreRoba
Copy link

Hi all, Thanks for this great library.

I was wondering if there is any reason why GraphQlResponse is not clonable?
I'm using it with yew and more specifically with yew-hook use_async and it requires the result to be clonable.

use cynic::{http::ReqwestExt, QueryBuilder};

let query = use_async(async move {
            let operation = ComputeAtnsQuery::build(vars);

            let client = reqwest::Client::new();
            client
                .post("https://swapi-graphql.netlify.app/.netlify/functions/index")
                .run_graphql(operation)
                .await
        });

I'm getting the error:

the trait bound `cynic::GraphQlResponse<components::administrator::salary::atn::query::ComputeAtnsQuery>: std::clone::Clone` is not satisfied [E0277]
@obmarg
Copy link
Owner

obmarg commented Jan 8, 2024

There's no real reason, happy to make it clonable

obmarg added a commit that referenced this issue Jan 8, 2024
@obmarg
Copy link
Owner

obmarg commented Jan 8, 2024

Fixed in v3.3.2

@AlexandreRoba
Copy link
Author

AlexandreRoba commented Jan 9, 2024

@obmarg Thanks a lot for your fast response. I've got now the same error for:

the trait bound `cynic::http::CynicReqwestError: std::clone::Clone` is not satisfied 

Can I ask you the same thing for it?
It is less important as I can map_or_err but it requires less code if it is :p. Again thanks for the help.

@obmarg
Copy link
Owner

obmarg commented Jan 9, 2024

@AlexandreRoba Unfortunately I can't help you on that one - CynicReqwestError contains reqwest::Error which isn't Clone.

You could map the Err like you suggest, or possibly put the whole thing inside an Arc or Rc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants