Implement intersection schema
@@ -24,7 +24,7 @@ pub use definitions::{
};
pub use errors::{Result, SchemaError};
use fb_schema::FlatBufferSchema;
-pub use graphql_syntax::DirectiveLocation;
+pub use graphql_syntax::{DirectiveLocation, TypeSystemDefinition};
pub use graphqlschema_generated::graphqlschema::*;
const BUILTINS: &str = include_str!("./builtins.graphql");
@@ -37,12 +37,7 @@ pub fn build_schema_with_extensions<T: AsRef<str>, U: AsRef<str>>(
server_sdls: &[T],
extension_sdls: &[U],
) -> DiagnosticsResult<Schema> {
- let mut server_definitions = {
- let schema_doc =
- graphql_syntax::parse_schema_document(BUILTINS, SourceLocationKey::generated())?;
- schema_doc.definitions
- };
-
+ let mut server_definitions = builtins()?;
let mut combined_sdl: String = String::new();
for server_sdl in server_sdls {
combined_sdl.push_str(server_sdl.as_ref());
@@ -70,3 +65,10 @@ pub fn build_schema_with_extensions<T: AsRef<str>, U: AsRef<str>>(
pub fn build_schema_from_flat_buffer(bytes: &[u8]) -> DiagnosticsResult<FlatBufferSchema<'_>> {
Ok(FlatBufferSchema::build(bytes))
}
+
+pub fn builtins() -> DiagnosticsResult<Vec<TypeSystemDefinition>> {
+ Ok(
+ graphql_syntax::parse_schema_document(BUILTINS, SourceLocationKey::generated())?
+ .definitions,
+ )
+}
