我需要杜松的帮助

我已将此文件https://github.com/graphql-rust/juniper/blob/master/juniper/src/tests/model.rs复制到我的项目中。

但是当我cargo run时,我得到:

error[E0432]: unresolved import `InputValue`
--> src/model.rs:5:10
|
5 | #[derive(GraphQLEnum, Copy, Clone, Eq, PartialEq, Debug)]
|

     ^^^^^^^^^^^ no `InputValue` in the root

我在InputValue中添加了main.rs,然后编译器需要另一个use。因此,即使在main.rs中也是如此:

use juniper::InputValue;
use juniper::Value;
use juniper::ToInputValue;
use juniper::FromInputValue;
use juniper::Executor;

我有:

error[E0365]: `InputValue` is private, and cannot be reexported
--> src/model.rs:5:10
|
5 | #[derive(GraphQLEnum, Copy, Clone, Eq, PartialEq, Debug)]
|          ^^^^^^^^^^^ reexport of private `InputValue`
|
= note: consider declaring type or module `InputValue` with `pub`

error[E0365]: `Value` is private, and cannot be reexported
--> src/model.rs:5:10
|
5 | #[derive(GraphQLEnum, Copy, Clone, Eq, PartialEq, Debug)]
|          ^^^^^^^^^^^ reexport of private `Value`
|
= note: consider declaring type or module `Value` with `pub`

等等...

最佳答案

错误所指向的代码是:

#[derive(GraphQLEnum, Copy, Clone, Eq, PartialEq, Debug)]
#[graphql(_internal)]
pub enum Episode {
    #[graphql(name = "NEW_HOPE")] NewHope,
    Empire,
    Jedi,
}

看起来您已复制了所有内容,包括#[graphql(_internal)]属性。从名称来看,它仅打算在瞻博测试套件内部使用,而不是像您这样的下游 crate 使用。删除_internal属性后,应该可以使用。使用以下lib.rs测试:
#[macro_use]
extern crate juniper;

mod model;

关于rust - Juniper和GraphQLEnum- Unresolved 导入InputValue,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48962903/

10-12 04:58