Skip to content

Cohesiveness between GraphQLQuery struct, its Variables and ResponseData #340

Open
@tomasol

Description

@tomasol

With current APIs it is possible to have mismatch between the struct, Variables and ResponseData . Example from the README.md:

    let request_body = UnionQuery::build_query(variables);
    let client = reqwest::Client::new();
    let mut res = client.post("/graphql").json(&request_body).send()?;
    let response_body: Response<union_query::ResponseData> = res.json()?;

The cast in the last line can be replaced with any other ResponseData without a compilation error.

I would like to know if there is interest in fixing the issue. I've prototyped a simple trait that solves the issue for me:

let response_body = UnionQuery::execute(variables, &client)?;

The client is actually a trait so it is not coupled with reqwest. I will add a PR with draft of the proposed API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions