Skip to content

Unable to derive from the GraphQLQuery Macro - Expected String but got &str #507

Description

@imjacobclark

Unable to derive from the GraphQLQuery Macro

Issue:

use graphql_client::{GraphQLQuery};
#[derive(GraphQLQuery)]
#[graphql(
    schema_path = "src/graphql/github_schema.graphql",
    query_path = "src/graphql/queries/QueryPullRequestData.graphql",
    response_derives = "Debug"
)]

pub struct GetRepositories; 

Error:

imjacobclark@mutt:~/workspace/flow/ingestor$ cargo run
   Compiling ingestor v0.1.0 (/home/imjacobclark/workspace/flow/ingestor)
error[E0308]: mismatched types
   --> ingestor/src/main.rs:18:10
    |
18  | #[derive(GraphQLQuery)]
    |          ^^^^^^^^^^^^
    |          |
    |          expected `String`, found `&str`
    |          arguments to this enum variant are incorrect

I tried to resolve in the following ways:

use graphql_client::{GraphQLQuery};
#[derive(GraphQLQuery)]
#[graphql(
    schema_path = String::from("src/graphql/github_schema.graphql"),
    query_path = String::from("src/graphql/queries/QueryPullRequestData.graphql"),
    response_derives = String::from("Debug"),
)]

pub struct GetRepositories; 

Error:

imjacobclark@mutt:~/workspace/flow/ingestor$ cargo run
   Compiling ingestor v0.1.0 (/home/imjacobclark/workspace/flow/ingestor)
error: proc-macro derive panicked
  --> ingestor/src/main.rs:18:10
   |
18 | #[derive(GraphQLQuery)]
   |          ^^^^^^^^^^^^
   |
   = help: message: Attribute is well formatted: Error("expected literal")

error: could not compile `ingestor` (bin "ingestor") due to 1 previous error

Versions:

graphql_client = "0.14.0"
imjacobclark@mutt:~/workspace/flow/ingestor$ rustc --version
rustc 1.83.0 (90b35a623 2024-11-26)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions