Skip to content

Commit

Permalink
another rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
obmarg committed Mar 11, 2024
1 parent f6dd0fa commit 3c80415
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
6 changes: 3 additions & 3 deletions cynic-codegen/src/schema/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::schema::load_schema;
use super::parser::SchemaLoadError;

pub enum SchemaInput {
Document(cynic_parser::type_system::Ast),
Document(cynic_parser::TypeSystemDocument),
#[cfg(feature = "rkyv")]
Archive(Vec<u8>),
}
Expand Down Expand Up @@ -62,7 +62,7 @@ impl SchemaInput {
}

pub fn from_sdl(sdl: &str) -> Result<SchemaInput, SchemaLoadError> {
load_schema(sdl).map(|ast| SchemaInput::Document(ast))
load_schema(sdl).map(SchemaInput::Document)
}

#[cfg(feature = "rkyv")]
Expand All @@ -78,7 +78,7 @@ impl SchemaInput {

fn document_from_path(
filename: impl AsRef<std::path::Path>,
) -> Result<Option<cynic_parser::type_system::Ast>, SchemaLoadError> {
) -> Result<Option<cynic_parser::TypeSystemDocument>, SchemaLoadError> {
use std::path::PathBuf;
let mut pathbuf = PathBuf::new();

Expand Down
2 changes: 1 addition & 1 deletion cynic-codegen/src/schema/parser.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// Loads a schema from a string
pub fn load_schema(sdl: &str) -> Result<cynic_parser::type_system::Ast, SchemaLoadError> {
pub fn load_schema(sdl: &str) -> Result<cynic_parser::TypeSystemDocument, SchemaLoadError> {
let ast = cynic_parser::parse_type_system_document(sdl)
.map_err(|error| SchemaLoadError::ParseError(error.to_string()))?;
Ok(ast)
Expand Down
18 changes: 8 additions & 10 deletions cynic-codegen/src/schema/type_index/schema_backed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::schema::{names::FieldName, types::*, SchemaError};

#[ouroboros::self_referencing]
pub struct SchemaBackedTypeIndex {
ast: cynic_parser::type_system::Ast,
ast: cynic_parser::TypeSystemDocument,
query_root: String,
mutation_root: Option<String>,
subscription_root: Option<String>,
Expand All @@ -25,7 +25,7 @@ pub struct SchemaBackedTypeIndex {
}

impl SchemaBackedTypeIndex {
pub fn for_schema(ast: cynic_parser::type_system::Ast) -> Self {
pub fn for_schema(ast: cynic_parser::TypeSystemDocument) -> Self {
let mut query_root = "Query".to_string();
let mut mutation_root = None;
let mut subscription_root = None;
Expand All @@ -41,7 +41,7 @@ impl SchemaBackedTypeIndex {
}
}

let mut writer = cynic_parser::type_system::writer::AstWriter::update(ast);
let mut writer = cynic_parser::type_system::writer::TypeSystemAstWriter::update(ast);
for builtin in BUILTIN_SCALARS {
let name = writer.ident(builtin);
writer.scalar_definition(cynic_parser::type_system::storage::ScalarDefinition {
Expand Down Expand Up @@ -213,7 +213,7 @@ impl super::TypeIndex for SchemaBackedTypeIndex {

impl SchemaBackedTypeIndex {
fn lookup_type<'a>(&'a self, name: &str) -> Option<TypeDefinition<'a>> {
self.borrow_types().get(name).map(|d| *d)
self.borrow_types().get(name).copied()
}

/// Validates that all the types contained within the given types do exist.
Expand Down Expand Up @@ -277,8 +277,7 @@ impl SchemaBackedTypeIndex {
validate!(name, Input);
}
}
for iface in obj.implements_interfaces() {
let name = iface.as_ref();
for name in obj.implements_interfaces() {
validate!(
name,
TypeDefinition::Interface(_),
Expand All @@ -304,8 +303,7 @@ impl SchemaBackedTypeIndex {
validate!(name, Input);
}
}
for iface in iface.implements_interfaces() {
let name = iface.as_ref();
for name in iface.implements_interfaces() {
validate!(
name,
TypeDefinition::Interface(_),
Expand Down Expand Up @@ -486,11 +484,11 @@ mod tests {
);
}

fn ast_for_type(sdl_ty: &str) -> cynic_parser::type_system::Ast {
fn ast_for_type(sdl_ty: &str) -> cynic_parser::TypeSystemDocument {
cynic_parser::parse_type_system_document(&format!("type Blah {{ foo: {sdl_ty} }}")).unwrap()
}

fn extract_type(ast: &cynic_parser::type_system::Ast) -> readers::Type<'_> {
fn extract_type(ast: &cynic_parser::TypeSystemDocument) -> readers::Type<'_> {
let readers::Definition::Type(readers::TypeDefinition::Object(obj)) =
ast.definitions().next().unwrap()
else {
Expand Down

0 comments on commit 3c80415

Please sign in to comment.