Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally include GraphQL Query / Mutation in querygen output #983

Open
bengsparks opened this issue Jun 11, 2024 · 0 comments
Open

Optionally include GraphQL Query / Mutation in querygen output #983

bengsparks opened this issue Jun 11, 2024 · 0 comments

Comments

@bengsparks
Copy link
Contributor

bengsparks commented Jun 11, 2024

$ cynic querygen --query query.graphql  --schema schema.graphql

Currently "only" outputs Rust structs with the correct #[derive(...)]s attached.
By prepending the contents of query.graphql to the output within a markdown code block, it becomes possible to document the generated code automatically.

Example:

schema.graphql:

type Query {
  helloWorld: String!
}

query.graphql

query HelloWorld {
    helloWorld
}

cynic querygen --query query.graphql --schema schema.graphql

#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query")]
pub struct HelloWorld {
    pub hello_world: String,
}

cynic querygen --query query.graphql --schema schema.graphql --structdoc

/// ```gql 
/// query HelloWorld {
///     helloWorld
/// }
/// ```
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query")]
pub struct HelloWorld {
    pub hello_world: String,
}

cynic querygen --query query.graphql --schema schema.graphql --moddoc

//! ```gql 
//! query HelloWorld {
//!     helloWorld
//! }
//! ```


#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query")]
pub struct HelloWorld {
    pub hello_world: String,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant