graphql-config 0.2.0

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

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