0.0.2 • Published 7 years ago

gcl-lib v0.0.2

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

GCL: GraphQL Configuration Language

GCL is intended to be a type-safe alternative to JSON, YAML (...) based on the input type syntax of GraphQL

Advantages

  • Autocompletion & validation for configuration files
  • Out-of-the-box documentation for config DSLs
  • Easy schema definition through SDL for tooling authors
  • Leverages available GraphQL tooling (parsers etc) for cross-language adoption

Example (Demo)

This example shows a configuration DSL for Docker images

Config File

Config files have the .gcl file extension

image: "node:6.10"
ports: ["80"]
networks: ["frontend"]
deploy: {
  replicas: 2
  update_config: {
    parallelism: 2
  }
  restart_policy: {
    condition: OnFailure
  }
}

Schema

The schema is specified by input types. The Root type is the "root" of the configuration schema.

input Root {
  image: String
  ports: [String!]
  networks: [String!]
  depends_on: [String!]
  volumes: [String!]
  deploy: Deploy
}

input Deploy {
  replicas: Int
  update_config: DeployUpdateConfig
  restart_policy: DeployRestartPolicy
}

input DeployUpdateConfig {
  parallelism: Int
}

enum DeployRestartPolicyCondition {
  OnFailure
}

input DeployRestartPolicy {
  condition: DeployRestartPolicyCondition
}

TODO

  • Decide on "Add back top level curly brackets #1"
  • PoC based on GraphiQL for auto-completion (removing the top-level query)
  • Integrate with graphql-language-service

GraphQL changes that would enhance GCL

  • Multi-line strings (PR)