All Projects â†’ prisma-archive â†’ gcl

prisma-archive / gcl

Licence: other
📖 Type-safe configuration format (similar to JSON/YAML) based on GraphQL with auto-completion and validation

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Labels

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)

Library Usage

import fs from 'fs'
import gclToJson from 'gcl-lib'

async function run() {
  const schema = fs.readFileSync('schema.graphql', 'utf-8')
  const config = fs.readFileSync('config.gcl', 'utf-8')

  const json = await gclToJson(config, schema)

  console.log(JSON.stringify(json, null, 2))
}

run()

CLI Usage

$ npm install -g gcl-lib
$ gcl-json -s schema.graphql -c config.gcl
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].