#graphql #specification #configuration #web #deserialize #following #projects

graphql-config

This crate provides deserialize for GraphQL configs following the graphql-config specification

2 unstable releases

Uses old Rust 2015

0.2.0 Jul 24, 2018
0.1.0 Jul 23, 2018

#49 in #following

Apache-2.0 OR MIT

15KB
199 lines

Build Status

graphql-config

This crate provides deserialize for GraphQL configs following the graphql-config specification.

GraphQLConfiguration is the type of the whole JSON document. It contains the top-level configuration (which serializes in the root field) and also optionally project-specific configuration in the projects field. The shapes of the top-level configuration and project-specific configurations are exactly the same.

This library does not support experimental configuration options yet.

Currently, this library follows the spec as per version 2.0.1 of the graphql-config specification.

Example

let config = json!({
    "schemaPath": "./schema.graphql",
    "includes": ["./graphql/*.graphql"],
    "projects": {
        "amazingLibrary": {
            "schemaPath": "./amazingLibrary.schema.graphql"
        }
    }
});

let expected = GraphQLConfiguration {
    root: GraphQLProjectConfiguration {
        name: None,
        schema_path: Some("./schema.graphql".into()),
        includes: Some(vec!["./graphql/*.graphql".to_owned()]),
        excludes: None,
        extensions: None,
    },
    projects: Some(btreemap!{
        "amazingLibrary".to_owned() => GraphQLProjectConfiguration {
            schema_path: Some("./amazingLibrary.schema.graphql".into()),
            name: None,
            includes: None,
            excludes: None,
            extensions: None,
        },
    }),
};

let deserialized = serde_json::from_value::<GraphQLConfiguration>(config)?;

assert_eq!(deserialized, expected);

License: Apache-2.0 OR MIT

Dependencies

~0.7–1.6MB
~35K SLoC