graphql-client icon indicating copy to clipboard operation
graphql-client copied to clipboard

[Qustion] How can i use null for graphql

Open liangyuanpeng opened this issue 5 years ago • 2 comments

In my case, i need to use null for graphql, some like :

stargazers(first: 1,after: null) {
...
}

I tried the way

query.graphql

query RepoView($owner: String!, $name: String!,$startFirst: Int,$after:Option) {
...
}

main.rs

let q = RepoView::build_query(repo_view::Variables {
        owner: owner.to_string(),
        name: name.to_string(),
        start_first: starFirst,
        after: Option::None,
    });

I just got the err and i just started using rust, how can i do for it ?!

Thanks any help!

liangyuanpeng avatar Jan 29 '20 05:01 liangyuanpeng

Let's try with this.

let q = RepoView::build_query(repo_view::Variables {
        owner: owner.to_string(),
        name: name.to_string(),
        start_first: starFirst,
        after: None,
    });

cptrodgers avatar Feb 26 '20 12:02 cptrodgers

Piggy-backing on this question, but it's related: Is there an easy way to model the implicit vs explicit null in a query, like https://graphql-rust.github.io/juniper/master/advanced/implicit_and_explicit_null.html ?

Basically, I'd like to be able to at will omit certain fields from the query. I guess I could do that with @include, but that's a bit ugly (requires an extra boolean argument for each optional field). Could we have something like juniper's Nullable?

nitnelave avatar Sep 01 '21 09:09 nitnelave