diff --git a/juniper/CHANGELOG.md b/juniper/CHANGELOG.md index 76b2002e..933dc4b8 100644 --- a/juniper/CHANGELOG.md +++ b/juniper/CHANGELOG.md @@ -1,6 +1,6 @@ # master -- No changes yet +- Allow `RootNode::as_schema_language` and `RootNode::as_parser_document` for arbitrary type info ([#935](https://github.com/graphql-rust/juniper/pull/935)) # [[0.15.5] 2021-05-11](https://github.com/graphql-rust/juniper/releases/tag/juniper-v0.15.5) diff --git a/juniper/src/schema/model.rs b/juniper/src/schema/model.rs index 4872d1a0..09d4c85e 100644 --- a/juniper/src/schema/model.rs +++ b/juniper/src/schema/model.rs @@ -118,22 +118,6 @@ where ) -> Self { RootNode::new_with_info(query, mutation, subscription, (), (), ()) } - - #[cfg(feature = "schema-language")] - /// The schema definition as a `String` in the - /// [GraphQL Schema Language](https://graphql.org/learn/schema/#type-language) - /// format. - pub fn as_schema_language(&self) -> String { - let doc = self.as_parser_document(); - format!("{}", doc) - } - - #[cfg(feature = "graphql-parser-integration")] - /// The schema definition as a [`graphql_parser`](https://crates.io/crates/graphql-parser) - /// [`Document`](https://docs.rs/graphql-parser/latest/graphql_parser/schema/struct.Document.html). - pub fn as_parser_document(&'a self) -> Document<'a, &'a str> { - GraphQLParserTranslator::translate_schema(&self.schema) - } } impl<'a, S, QueryT, MutationT, SubscriptionT> RootNode<'a, QueryT, MutationT, SubscriptionT, S> @@ -168,6 +152,22 @@ where subscription_info, } } + + #[cfg(feature = "schema-language")] + /// The schema definition as a `String` in the + /// [GraphQL Schema Language](https://graphql.org/learn/schema/#type-language) + /// format. + pub fn as_schema_language(&self) -> String { + let doc = self.as_parser_document(); + format!("{}", doc) + } + + #[cfg(feature = "graphql-parser-integration")] + /// The schema definition as a [`graphql_parser`](https://crates.io/crates/graphql-parser) + /// [`Document`](https://docs.rs/graphql-parser/latest/graphql_parser/schema/struct.Document.html). + pub fn as_parser_document(&'a self) -> Document<'a, &'a str> { + GraphQLParserTranslator::translate_schema(&self.schema) + } } impl<'a, S> SchemaType<'a, S> {