Skip to content

Add into_static for schema::Document #33

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

Merged
merged 1 commit into from
Jun 23, 2020
Merged

Conversation

obmarg
Copy link
Contributor

@obmarg obmarg commented Jun 13, 2020

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.

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

```rust
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 tailhook merged commit 98e7446 into graphql-rust:master Jun 23, 2020
@tailhook
Copy link
Collaborator

Merged. Thanks!

@obmarg
Copy link
Contributor Author

obmarg commented Jul 1, 2020

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

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

Successfully merging this pull request may close these issues.

2 participants