Why does adding graphql-client as dependency cause rover to break? - rust

I am setting up this project to help me pass authorization data between each subgraphs. I have an authorization subgraph to gather the data so the router will have to make a graphql query to the authorization subgraph and then pass it along. I picked graphql_client dependency because it's the same one that Apollo uses and it seems to have a lot of support compare to the other Rust graphql clients however when I add this dependency, it breaks another dependency. These are the steps
set up context example project -> https://github.com/apollographql/router/tree/v0.1.0-preview.6/examples/context
add these as dependency in Cargo.toml
graphql_client = { version = "0.10.0", features = ["reqwest-blocking"] }
reqwest = { version = "0.11.10", features = ["blocking"] }
run cargo build
see error
Compiling launchpad v0.1.0 (https://github.com/apollographql/rover.git?rev=94141242ba34cf00cde9630fc4a6dcd05d4fa5da#94141242)
error[E0433]: failed to resolve: use of undeclared type `HeaderMap`
--> /Users/macuser/.cargo/git/checkouts/rover-efd9f422be37a06b/9414124/crates/launchpad/src/introspect/runner.rs:30:26
|
30 | let mut header_map = HeaderMap::new();
| ^^^^^^^^^ not found in this scope
|
help: consider importing this struct
|
1 | use reqwest::header::HeaderMap;
|
error[E0433]: failed to resolve: use of undeclared type `HeaderName`
--> /Users/macuser/.cargo/git/checkouts/rover-efd9f422be37a06b/9414124/crates/launchpad/src/introspect/runner.rs:33:13
|
33 | HeaderName::from_bytes(header_key.as_bytes())?,
| ^^^^^^^^^^ not found in this scope
|
help: consider importing this struct
|
1 | use reqwest::header::HeaderName;
|
error[E0433]: failed to resolve: use of undeclared type `HeaderValue`
--> /Users/macuser/.cargo/git/checkouts/rover-efd9f422be37a06b/9414124/crates/launchpad/src/introspect/runner.rs:34:13
|
34 | HeaderValue::from_str(&header_value)?,
| ^^^^^^^^^^^ not found in this scope
|
help: consider importing this struct
|
1 | use reqwest::header::HeaderValue;
|
error[E0659]: `reqwest` is ambiguous
--> /Users/macuser/.cargo/git/checkouts/rover-efd9f422be37a06b/9414124/crates/launchpad/src/introspect/runner.rs:6:5
|
6 | use reqwest::header::{HeaderMap, HeaderName, HeaderValue};
| ^^^^^^^ ambiguous name
|
= note: ambiguous because of multiple potential import sources
= note: `reqwest` could refer to a crate passed with `--extern`
= help: use `::reqwest` to refer to this crate unambiguously
note: `reqwest` could also refer to the module imported here
--> /Users/macuser/.cargo/git/checkouts/rover-efd9f422be37a06b/9414124/crates/launchpad/src/introspect/runner.rs:5:5
|
5 | use graphql_client::*;
| ^^^^^^^^^^^^^^^^^
= help: use `self::reqwest` to refer to this module unambiguously
Dependency tree is apollo router -> uplink -> rover (branch = geal/launchpad)

I posted this same issue on apollo/router repo and they said it'll be fix soon
https://github.com/apollographql/router/issues/937#issuecomment-1114995491

You need to configure your subgraph to receive it.

Related

cannot change #![recursion_limit = "256"] in generated schema.rs using diesel print-schema

I'm trying to implement a microservice using rust and i'm starting generating the whole model of monolithic application with 400+ tables with 200+ column in some cases.
I generated schema using:
diesel print-schema > src/schema.rs
and model with diesel_ext
`diesel_ext --model > src/models.rs`
When i build my code i got the following error:
error: recursion limit reached while expanding `__diesel_parse_columns!`
--> src/schema.rs:22:1
|
22 | / table! {
23 | | agreement (id) {
24 | | id -> Int4,
25 | | deleted -> Bool,
... |
267 | | }
268 | | }
| |_^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`generatore_offerte`)
= note: this error originates in the macro `__diesel_parse_columns` (in Nightly builds, run with -Z macro-backtrace for more info)
I tried to place #![recursion_limit = "256"] in main, lib, models, schema, everywhere but the error is always the same.
Where i need to place this settings to solve this error?
Ok finally it worked,
probably there was something else missed too.
It worked when i placed #![recursion_limit = "256"] only in my lib.rs

Bad enforcement of clippy rule?

I have disallowed unrelated shadowing in variable declarations.
But now this rule gives me an error on these two lines
let overflow: bool;
(self.standing, overflow) = self.standing.overflowing_add(reason.to_severity());
The linting error I get is:
error: `overflow` shadows a previous, unrelated binding
--> src/models/peer.rs:73:25
|
73 | (self.standing, overflow) = self.standing.overflowing_add(reason.to_severity());
| ^^^^^^^^
|
note: the lint level is defined here
--> src/lib.rs:1:9
|
1 | #![deny(clippy::shadow_unrelated)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
note: previous binding is here
--> src/models/peer.rs:73:10
|
73 | (self.standing, overflow) = self.standing.overflowing_add(reason.to_severity());
| ^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#shadow_unrelated
I'm using version 1.62.0 of the rust compiler.
My thoughts are that this behavior is a bug. The above lines should be allowed under this clippy rule. Am I wrong?
The problem can be seen here. Thanks to #Jmp for writing an this illustration of the problem.
This is a reported bug - rust-clippy#6141.
I think the problem is that the destructuring assignment is desugared into a let declaration that reuses the same span, and this causes clippy to think it has the same name and thus shadowing.

Rust config::builder::ConfigBuilder with static string source?

I am using the Rust config crate and want to switch from loading configuration from a file at runtime to a static string created at compile time.
Right now, it works like this:
config::Config::builder().add_source(File::new("default.toml", FileFormat::Toml));
However when I try it with a static string, it does not:
static DEFAULT: &str = std::include_str!("./default.toml");
[...]
config::Config::builder().add_source(DEFAULT)
Error Message
error[E0277]: the trait bound `&str: Source` is not satisfied
--> src/config.rs:21:25
|
21 | .add_source(DEFAULT)
| ---------- ^^^^^^^ the trait `Source` is not implemented for `&str`
| |
| required by a bound introduced by this call
|
note: required by a bound in `ConfigBuilder::<DefaultState>::add_source`
--> /home/konrad/.cargo/registry/src/github.com-1ecc6299db9ec823/config-0.13.1/src/builder.rs:207:12
|
207 | T: Source + Send + Sync + 'static,
| ^^^^^^ required by this bound in `ConfigBuilder::<DefaultState>::add_source`
How can I read my config from a static string instead of a file?
Use File::from_str():
config::Config::builder().add_source(File::from_str(DEFAULT, FileFormat::Toml));

How to disable "unnecessary path disambiguator" warning?

I am generating code with a macro, which contains fully qualified type paths like this:
let vec: Vec::<String>;
Note the extra :: before <String>. This is necessary so that the same input token can be also be used for the constructor, by appending ::new():
Vec::<String>::new()
However, this produces warnings:
warning: unnecessary path disambiguator
--> src/main.rs:4:17
|
4 | let vec: Vec::<String>;
| ^^ try removing `::`
I can't remove the :: because then I get an error:
error: chained comparison operators require parentheses
--> src/main.rs:6:14
|
6 | vec = Vec<String>::new();
| ^^^^^^^^^^
|
= help: use `::<...>` instead of `<...>` if you meant to specify type arguments
= help: or use `(...)` if you meant to specify fn arguments
error[E0423]: expected value, found struct `Vec`
--> src/main.rs:6:11
|
6 | vec = Vec<String>::new();
| ^^^
| |
| did you mean `vec`?
| did you mean `Vec { /* fields */ }`?
How can I disable the warning just for this one line?
It is an open issue currently.
This lint is currently slipping these attributes like #![allow(warnings)]
Reference

Cargo rand compilation errors

This is a really basic question so please bear with me.
I have a project that needs to use an old build of Rust (cargo 0.19.0-nightly c995e9e 2017-03-17). It uses rand so I added rand="0.4.3" as a dependency. When the registry updates, rand 0.5.5 (latest) is automatically downloaded and it also runs into "break loop" error which was stabilized a while ago. I am not sure how to suppress this error or make it not install the latest version.
Cargo.toml:
[package]
name = "hello-world"
version = "0.0.0"
authors = [""]
[dependencies]
time = ">=0.1.0"
rand = "=0.4.3"
rustc-serialize ="0.3"
histogram = "*"
I get this error. The repository is not cloned locally so I cannot apply the patch rust-lang/rust#37339.
Compiling rand v0.5.5 error: break with a value is experimental (see
issue #37339)
--> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.5.5/src/distributions/uniform.rs:674:25
| 674 | break d; | ^^^^^^^ |
= help: add #![feature(loop_break_value)] to the crate attributes to enable
error: pub(restricted) syntax is experimental (see issue #32409)
--> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.5.5/src/distributions/float.rs:71:5
| 71 | pub(crate) trait IntoFloat { | ^^^^^ |
= help: add #![feature(pub_restricted)] to the crate attributes to enable
error: pub(restricted) syntax is experimental (see issue #32409)
--> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.5.5/src/rngs/mod.rs:174:27
| 174 | #[cfg(feature="std")] pub(crate) mod thread; | ^^^^^ |
= help: add #![feature(pub_restricted)] to the crate attributes to enable
error: aborting due to 3 previous errors
error: Could not compile rand.
What am i doing wrong? What is the right way to go about it?

Resources