Merge pull request #55 from theduke/custom_derive

Restructure repo, add custom derive and integration tests.
This commit is contained in:
Magnus Hallin 2017-07-16 10:02:38 +02:00 committed by GitHub
commit 2ffa31bbc0
111 changed files with 894 additions and 60 deletions

View file

@ -19,7 +19,8 @@ env:
- secure: "SsepHEYRmW9ee3RhxPpqGuPigZINFfA/yOwUJFseQt4t+Zs90r1xdl3Q8eDfPlnvBsL7Rd0QQrFDO7JUaimVLlgQkUnrl62o0CYzkodp+qtocyAHS00W6WTqi8Y6E6KBxPshCl03dRLaySUfx5TqTLTIHkJ0G6vDW35k7hRrA3221lRphs5rrpvAZ21pqsDsNLH3HVo792L6A0kOtBa3ocw1pgHLxnBbArIViu2htUuFvY/TgsmVbAdlow0efw/xkcJ/p0/r5q7igLek6Iqk8udfRc7CktvoiFQ2vUnhtNtQu/zYll3Q7OUx5d+w5lhbzz2QINmsezBEisH9k1haL7dMviLPp0pn4WZed60KovO0Iqfgjy1utTaKvJVfNWYsgkfU8c9a/z2rcZOKwXNKQW2ptBrtVjaB9dk7eMoyuFCDZwNtKqvG+ZKmvMpun+R8mmx+buOmN8Vlf5ygIoGxz3nbEtlLYGVTXHfdXXqRkFIwtiYVJEO7SLRKT9pbx1E++ARsi2+y8bXJT4e4z0osYMq9EsiFUpw3J2gcshrgseqkB7UgCZ3SXuitJnJNfDAU3a3nwwS/JiAunZMNnC4rKUBbl7WbTB4Cpw7EgVOlCqcyyzlkNl3xabLzTFzLOfSHLTVX5FmGNsD21vBoS5/8ejftx9wuV3rGHxuO3i3+A3k="
script:
# Build library standalone, with Iron, and with Rocket integrations enabled, respectively
# Build and run tests for main juniper crate with certain features.
- cd juniper
- cargo build --verbose
- cargo build --verbose --features iron-handlers
- |
@ -42,6 +43,19 @@ script:
fi
- cargo test --verbose --features "$TEST_FEATURES"
- cd ..
# Build juniper_codegen and run tests.
- cd juniper_codegen
- cargo build --verbose
- cargo test
- cd ..
# Build and run integration tests.
- cd juniper_tests
- cargo build --verbose
- cargo test
before_deploy:

View file

@ -1,57 +1,6 @@
[package]
name = "juniper"
version = "0.8.1"
authors = ["Magnus Hallin <mhallin@fastmail.com>"]
description = "GraphQL server library"
license = "BSD-2-Clause"
documentation = "https://docs.rs/juniper/0.8.1/juniper/"
repository = "https://github.com/mhallin/juniper"
readme = "README.md"
keywords = ["graphql", "server", "iron", "web", "rocket"]
categories = ["web-programming"]
[package.metadata.docs.rs]
features = [ "iron-handlers" ]
[badges]
travis-ci = { repository = "mhallin/juniper" }
appveyor = { repository = "mhallin/juniper" }
[[bench]]
name = "bench"
harness = false
path = "benches/bench.rs"
[[example]]
name = "server"
required-features = ["iron-handlers", "expose-test-schema"]
[[example]]
name = "rocket-server"
required-features = ["rocket-handlers", "expose-test-schema"]
[features]
nightly = []
iron-handlers = ["iron", "serde_json", "urlencoded"]
rocket-handlers = ["rocket", "rocket_codegen", "serde_json"]
expose-test-schema = []
[dependencies]
serde = { version = "^1.0.8" }
serde_derive = {version="^1.0.8" }
serde_json = { version = "^1.0.2", optional = true }
iron = { version = "^0.5.1", optional = true }
urlencoded = { version = "^0.5.0", optional = true }
rocket = { version = "^0.2.8", optional = true }
rocket_codegen = { version = "^0.2.8", optional = true }
[dev-dependencies]
iron = "^0.5.1"
router = "^0.5.0"
mount = "^0.3.0"
logger = "^0.3.0"
iron-test = "^0.5.0"
bencher = "^0.1.2"
[workspace]
members = [
"juniper",
"juniper_codegen",
"juniper_tests",
]

View file

@ -48,8 +48,8 @@ install:
build: false
test_script:
# Build library standalone, with Iron, and with Rocket integrations enabled, respectively
- cargo build --verbose
# Build and test main juniper crate with certain features.
- cd juniper
- cargo build --verbose --features iron-handlers
- IF "%CHANNEL%"=="nightly" (cargo build --verbose --features rocket-handlers)
@ -62,3 +62,16 @@ test_script:
- IF "%CHANNEL%"=="nightly" (set TEST_FEATURES=%TEST_FEATURES% rocket-handlers rocket/testing)
- cargo test --verbose --features "%TEST_FEATURES%"
- cd ..
# Build juniper_codegen and run tests.
- cd juniper_codegen
- cargo build --verbose
- cargo test
- cd ..
# Build and run integration tests.
- cd juniper_tests
- cargo build --verbose
- cargo test

57
juniper/Cargo.toml Normal file
View file

@ -0,0 +1,57 @@
[package]
name = "juniper"
version = "0.8.1"
authors = ["Magnus Hallin <mhallin@fastmail.com>"]
description = "GraphQL server library"
license = "BSD-2-Clause"
documentation = "https://docs.rs/juniper/0.8.1/juniper/"
repository = "https://github.com/mhallin/juniper"
readme = "README.md"
keywords = ["graphql", "server", "iron", "web", "rocket"]
categories = ["web-programming"]
[package.metadata.docs.rs]
features = [ "iron-handlers" ]
[badges]
travis-ci = { repository = "mhallin/juniper" }
appveyor = { repository = "mhallin/juniper" }
[[bench]]
name = "bench"
harness = false
path = "benches/bench.rs"
[[example]]
name = "server"
required-features = ["iron-handlers", "expose-test-schema"]
[[example]]
name = "rocket-server"
required-features = ["rocket-handlers", "expose-test-schema"]
[features]
nightly = []
iron-handlers = ["iron", "serde_json", "urlencoded"]
rocket-handlers = ["rocket", "rocket_codegen", "serde_json"]
expose-test-schema = []
[dependencies]
serde = { version = "^1.0.8" }
serde_derive = {version="^1.0.8" }
serde_json = { version = "^1.0.2", optional = true }
iron = { version = "^0.5.1", optional = true }
urlencoded = { version = "^0.5.0", optional = true }
rocket = { version = "^0.2.8", optional = true }
rocket_codegen = { version = "^0.2.8", optional = true }
[dev-dependencies]
iron = "^0.5.1"
router = "^0.5.0"
mount = "^0.3.0"
logger = "^0.3.0"
iron-test = "^0.5.0"
bencher = "^0.1.2"

64
juniper/appveyor.yml Normal file
View file

@ -0,0 +1,64 @@
# Build and test on stable, beta, and nightly on Windows.
#
# Copied general structure from https://github.com/japaric/rust-everywhere/blob/master/appveyor.yml
environment:
matrix:
# Stable channel
- TARGET: i686-pc-windows-gnu
CHANNEL: stable
- TARGET: i686-pc-windows-msvc
CHANNEL: stable
- TARGET: x86_64-pc-windows-gnu
CHANNEL: stable
- TARGET: x86_64-pc-windows-msvc
CHANNEL: stable
# Beta channel
- TARGET: i686-pc-windows-gnu
CHANNEL: beta
- TARGET: i686-pc-windows-msvc
CHANNEL: beta
- TARGET: x86_64-pc-windows-gnu
CHANNEL: beta
- TARGET: x86_64-pc-windows-msvc
CHANNEL: beta
# Nightly channel
- TARGET: i686-pc-windows-gnu
CHANNEL: nightly
- TARGET: i686-pc-windows-msvc
CHANNEL: nightly
- TARGET: x86_64-pc-windows-gnu
CHANNEL: nightly
- TARGET: x86_64-pc-windows-msvc
CHANNEL: nightly
# Install Rust and Cargo
# (Based on from https://github.com/rust-lang/libc/blob/master/appveyor.yml)
install:
- curl -sSf -o rustup-init.exe https://win.rustup.rs
- rustup-init.exe --default-host %TARGET% --default-toolchain %CHANNEL% -y
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- rustc -Vv
- cargo -V
# 'cargo test' takes care of building for us, so disable Appveyor's build stage. This prevents
# the "directory does not contain a project or solution file" error.
# source: https://github.com/starkat99/appveyor-rust/blob/master/appveyor.yml#L113
build: false
test_script:
# Build library standalone, with Iron, and with Rocket integrations enabled, respectively
- cargo build --verbose
- cargo build --verbose --features iron-handlers
- IF "%CHANNEL%"=="nightly" (cargo build --verbose --features rocket-handlers)
# Build example binaries; first Iron, then Rocket examples
- cargo build --verbose --example server --features "iron-handlers expose-test-schema"
- IF "%CHANNEL%"=="nightly" (cargo build --verbose --example rocket-server --features "rocket-handlers expose-test-schema")
# Run all tests for the base library and available integrations
- set TEST_FEATURES=iron-handlers expose-test-schema
- IF "%CHANNEL%"=="nightly" (set TEST_FEATURES=%TEST_FEATURES% rocket-handlers rocket/testing)
- cargo test --verbose --features "%TEST_FEATURES%"

127
juniper/benches/bench.rs Normal file
View file

@ -0,0 +1,127 @@
#[macro_use] extern crate bencher;
extern crate juniper;
use bencher::Bencher;
use juniper::{execute, RootNode, EmptyMutation, Variables};
use juniper::tests::model::Database;
fn query_type_name(b: &mut Bencher) {
let database = Database::new();
let schema = RootNode::new(&database, EmptyMutation::<Database>::new());
let doc = r#"
query IntrospectionQueryTypeQuery {
__schema {
queryType {
name
}
}
}"#;
b.iter(|| execute(doc, None, &schema, &Variables::new(), &database));
}
fn introspection_query(b: &mut Bencher) {
let database = Database::new();
let schema = RootNode::new(&database, EmptyMutation::<Database>::new());
let doc = r#"
query IntrospectionQuery {
__schema {
queryType { name }
mutationType { name }
subscriptionType { name }
types {
...FullType
}
directives {
name
description
locations
args {
...InputValue
}
}
}
}
fragment FullType on __Type {
kind
name
description
fields(includeDeprecated: true) {
name
description
args {
...InputValue
}
type {
...TypeRef
}
isDeprecated
deprecationReason
}
inputFields {
...InputValue
}
interfaces {
...TypeRef
}
enumValues(includeDeprecated: true) {
name
description
isDeprecated
deprecationReason
}
possibleTypes {
...TypeRef
}
}
fragment InputValue on __InputValue {
name
description
type { ...TypeRef }
defaultValue
}
fragment TypeRef on __Type {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
}
}
}
}
}
}
}
}
"#;
b.iter(|| execute(doc, None, &schema, &Variables::new(), &database));
}
benchmark_group!(queries, query_type_name, introspection_query);
benchmark_main!(queries);

Some files were not shown because too many files have changed in this diff Show more