Skip to content

Commit

Permalink
Improve docs and eliminate warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tailhook committed Feb 11, 2018
1 parent 0122cc5 commit 0a330ce
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 14 deletions.
7 changes: 3 additions & 4 deletions README.md
Expand Up @@ -5,15 +5,14 @@ GraphQL Parser
[Github](https://github.com/tailhook/graphql-parser) |
[Crate](https://crates.io/crates/graphql-parser)

A parser, formatter and AST for graphql query language for rust.
A parser, formatter and AST for graphql query and schema definition language
for rust.

Current this library supports full graphql syntax, and the following
extensions:
Supported extensions:

1. Subscriptions
2. Block (triple quoted) strings

Schema definition language (also often called IDL) is on the to do list.

License
=======
Expand Down
52 changes: 52 additions & 0 deletions src/lib.rs
Expand Up @@ -13,6 +13,7 @@
//!
//! 1. Subscriptions
//! 2. Block (triple quoted) strings
//! 3. Schema definition language a/k/a IDL (which is still in RFC)
//!
//!
//! Example: Parse and Format Query
Expand All @@ -39,6 +40,57 @@
//! # }
//! ```
//!
//! Example: Parse and Format Schema
//! --------------------------------
//!
//! ```rust
//! # extern crate failure;
//! # extern crate graphql_parser;
//! use graphql_parser::parse_schema;
//!
//! # fn parse() -> Result<(), failure::Error> {
//! let ast = parse_schema(r#"
//! schema {
//! query: Query
//! }
//! type Query {
//! users: [User!]!,
//! }
//! """
//! Example user object
//!
//! This is just a demo comment.
//! """
//! type User {
//! name: String!,
//! }
//! "#)?;
//! // Format canonical representation
//! assert_eq!(format!("{}", ast), "\
//! schema {
//! query: Query
//! }
//!
//! type Query {
//! users: [User!]!
//! }
//!
//! \"\"\"
//! Example user object
//!
//! This is just a demo comment.
//! \"\"\"
//! type User {
//! name: String!
//! }
//! ");
//! # Ok(())
//! # }
//! # fn main() {
//! # parse().unwrap()
//! # }
//! ```
//!
#![warn(missing_debug_implementations)]

extern crate combine;
Expand Down
2 changes: 0 additions & 2 deletions src/query/ast.rs
Expand Up @@ -5,8 +5,6 @@
//!
//! [graphql grammar]: http://facebook.github.io/graphql/October2016/#sec-Appendix-Grammar-Summary
//!
use std::collections::BTreeMap;

use position::Pos;
pub use common::{Directive, Number, Value, Name, Type};

Expand Down
12 changes: 5 additions & 7 deletions src/query/grammar.rs
@@ -1,12 +1,10 @@
use combine::{parser, ParseResult, Parser};
use combine::easy::Error;
use combine::error::StreamError;
use combine::combinator::{many, many1, eof, optional, position};
use combine::combinator::{many1, eof, optional, position};

use common::{Directive, Name, Value, Type};
use common::{directives, arguments, default_value, value, parse_type};
use tokenizer::{Kind as T, Token, TokenStream};
use helpers::{punct, ident, kind, name};
use common::{Directive};
use common::{directives, arguments, default_value, parse_type};
use tokenizer::{TokenStream};
use helpers::{punct, ident, name};
use query::error::{QueryParseError};
use query::ast::*;

Expand Down
2 changes: 2 additions & 0 deletions src/query/mod.rs
@@ -1,3 +1,5 @@
//! Query language AST and parsing utilities
//!
mod ast;
mod error;
mod format;
Expand Down
1 change: 0 additions & 1 deletion src/schema/ast.rs
@@ -1,5 +1,4 @@
use std::str::FromStr;
use std::collections::HashSet;

pub use common::{Directive, Type, Name, Value};
use position::Pos;
Expand Down
2 changes: 2 additions & 0 deletions src/schema/mod.rs
@@ -1,3 +1,5 @@
//! Schema definition language AST and utility
//!
mod ast;
mod grammar;
mod error;
Expand Down

0 comments on commit 0a330ce

Please sign in to comment.