Skip to content

Commit 0a330ce

Browse files
committed
Improve docs and eliminate warnings
1 parent 0122cc5 commit 0a330ce

File tree

7 files changed

+64
-14
lines changed

7 files changed

+64
-14
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ GraphQL Parser
55
[Github](https://github.com/tailhook/graphql-parser) |
66
[Crate](https://crates.io/crates/graphql-parser)
77

8-
A parser, formatter and AST for graphql query language for rust.
8+
A parser, formatter and AST for graphql query and schema definition language
9+
for rust.
910

10-
Current this library supports full graphql syntax, and the following
11-
extensions:
11+
Supported extensions:
1212

1313
1. Subscriptions
1414
2. Block (triple quoted) strings
1515

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

1817
License
1918
=======

src/lib.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//!
1414
//! 1. Subscriptions
1515
//! 2. Block (triple quoted) strings
16+
//! 3. Schema definition language a/k/a IDL (which is still in RFC)
1617
//!
1718
//!
1819
//! Example: Parse and Format Query
@@ -39,6 +40,57 @@
3940
//! # }
4041
//! ```
4142
//!
43+
//! Example: Parse and Format Schema
44+
//! --------------------------------
45+
//!
46+
//! ```rust
47+
//! # extern crate failure;
48+
//! # extern crate graphql_parser;
49+
//! use graphql_parser::parse_schema;
50+
//!
51+
//! # fn parse() -> Result<(), failure::Error> {
52+
//! let ast = parse_schema(r#"
53+
//! schema {
54+
//! query: Query
55+
//! }
56+
//! type Query {
57+
//! users: [User!]!,
58+
//! }
59+
//! """
60+
//! Example user object
61+
//!
62+
//! This is just a demo comment.
63+
//! """
64+
//! type User {
65+
//! name: String!,
66+
//! }
67+
//! "#)?;
68+
//! // Format canonical representation
69+
//! assert_eq!(format!("{}", ast), "\
70+
//! schema {
71+
//! query: Query
72+
//! }
73+
//!
74+
//! type Query {
75+
//! users: [User!]!
76+
//! }
77+
//!
78+
//! \"\"\"
79+
//! Example user object
80+
//!
81+
//! This is just a demo comment.
82+
//! \"\"\"
83+
//! type User {
84+
//! name: String!
85+
//! }
86+
//! ");
87+
//! # Ok(())
88+
//! # }
89+
//! # fn main() {
90+
//! # parse().unwrap()
91+
//! # }
92+
//! ```
93+
//!
4294
#![warn(missing_debug_implementations)]
4395

4496
extern crate combine;

src/query/ast.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
//!
66
//! [graphql grammar]: http://facebook.github.io/graphql/October2016/#sec-Appendix-Grammar-Summary
77
//!
8-
use std::collections::BTreeMap;
9-
108
use position::Pos;
119
pub use common::{Directive, Number, Value, Name, Type};
1210

src/query/grammar.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
use combine::{parser, ParseResult, Parser};
2-
use combine::easy::Error;
3-
use combine::error::StreamError;
4-
use combine::combinator::{many, many1, eof, optional, position};
2+
use combine::combinator::{many1, eof, optional, position};
53

6-
use common::{Directive, Name, Value, Type};
7-
use common::{directives, arguments, default_value, value, parse_type};
8-
use tokenizer::{Kind as T, Token, TokenStream};
9-
use helpers::{punct, ident, kind, name};
4+
use common::{Directive};
5+
use common::{directives, arguments, default_value, parse_type};
6+
use tokenizer::{TokenStream};
7+
use helpers::{punct, ident, name};
108
use query::error::{QueryParseError};
119
use query::ast::*;
1210

src/query/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Query language AST and parsing utilities
2+
//!
13
mod ast;
24
mod error;
35
mod format;

src/schema/ast.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::str::FromStr;
2-
use std::collections::HashSet;
32

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

src/schema/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Schema definition language AST and utility
2+
//!
13
mod ast;
24
mod grammar;
35
mod error;

0 commit comments

Comments
 (0)