graphql-rust / graphql-parser

A graphql query language and schema definition language parser and formatter for rust
Apache License 2.0
355 stars 77 forks source link

Add `into_static` for schema::Document #33

Closed obmarg closed 4 years ago

obmarg commented 4 years ago

I'm running into issues using schema::Document with strings. I have a function that looks roughly like this:

fn load_schema(filename: String) -> schema::Document<'static, String> {
    let schema = std::fs::read_to_string(filename);

    graphql_parser::schema::parse_schema<String>(&schema).unwrap()
}

However this won't compile, because the generated Document has taken a lifetime from schema which doesn't outlive the function.

I was looking around the library and saw that the query::Document has an into_static function when using Strings which resolves this. This duplicates that functionality for schema::Document.

tailhook commented 4 years ago

Merged. Thanks!

obmarg commented 4 years ago

Thanks for merging @tailhook - any idea when this might make it's way into a release?