Skip to content
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

Query visitor with schema type info #54

Closed
wants to merge 9 commits into from
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ thiserror = "1.0.11"

[dev-dependencies]
pretty_assertions = "0.5.0"
k9 = "0.11.0"
18 changes: 18 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use combine::easy::Error;
use combine::error::StreamError;
use combine::combinator::{many, many1, optional, position, choice};

use crate::schema::{EnumType, InputObjectType, InterfaceType, ObjectType, ScalarType, UnionType};
use crate::tokenizer::{Kind as T, Token, TokenStream};
use crate::helpers::{punct, ident, kind, name};
use crate::position::Pos;
Expand Down Expand Up @@ -65,6 +66,23 @@ pub enum Type<'a, T: Text<'a>> {
NonNullType(Box<Type<'a, T>>),
}

#[derive(Debug, Clone, PartialEq)]
pub enum CompositeType<'a, T: Text<'a>> {
Object(ObjectType<'a, T>),
Interface(InterfaceType<'a, T>),
Union(UnionType<'a, T>),
}

#[derive(Debug, Clone, PartialEq)]
pub enum InputType<'a, T: Text<'a>> {
Scalar(ScalarType<'a, T>),
Enum(EnumType<'a, T>),
InputObject(InputObjectType<'a, T>),
List(Box<InputType<'a, T>>),
NonNullType(Box<InputType<'a, T>>),
}


impl Number {
/// Returns a number as i64 if it fits the type
pub fn as_i64(&self) -> Option<i64> {
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@


mod common;

#[macro_use]
mod format;
mod position;
mod tokenizer;
mod helpers;
pub mod query;
pub mod schema;
pub mod validation;

pub use crate::query::parse_query;
pub use crate::schema::parse_schema;
Expand Down
1 change: 1 addition & 0 deletions src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod ast;
mod error;
mod format;
mod grammar;
pub mod query_visitor;


pub use self::grammar::{parse_query, consume_definition};
Expand Down
Loading