Skip to content

Error in importing .graphql files generated in the build process #339

Open
@noritada

Description

@noritada

I am trying to use a .graphql file generated in the build process using build.rs instead of a static one.

However, changing lines

#[derive(GraphQLQuery)]
#[graphql(
    schema_path = "src/schema.graphql",
    query_path = "src/query.graphql",
)]
struct Something;

into

#[derive(GraphQLQuery)]
#[graphql(
    schema_path = concat!(env!("OUT_DIR"), "/schema.graphql"),
    query_path = "src/query.graphql",
)]
struct Something;

results in a following error (and subsequent errors).

error: proc-macro derive panicked
 --> src/main.rs:8:10
  |
8 | #[derive(GraphQLQuery)]
  |          ^^^^^^^^^^^^
  |
  = help: message: Attribute is well formatted: Error("expected literal")

(Is this a limitation of this library or a syntactic limitation of Rust?)

IMHO generating and importing .graphql files is not a rare case and it would be nice if we can have such code or some other alternative options. (If graphql-rust already have some ways to do this, sorry.)

Many thanks,

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions