core/schema/README.md
This directory contains a proposal for a complete GraphQL API for Dagger. It is written with the following goals in mind:
Some problems in the DX that are not yet resolved, and this proposal would help solve, include:
withX and withoutXTo avoid the use of rpc-style verbs (a graphql best practice) and maximize chaining (a strength of our DX), we use the terminology withX and withoutX.
A field of the form withX returns the same object with content X added or changed.
Example:
"An empty directory with a README copied to it"
query readmeDir($readme: FileID!) {
directory {
withFile(source: $readme, path: "README.md") {
id
}
}
"An empty container with an app directory mounted into it"
query appContainer($app: DirectoryID!) {
container {
withMountedDirectory(source: $app, path: "/app") {
id
}
}
}
A field of the form withoutX returns the same object with content X removed.
"Remove node_modules from a JS project"
query removeNodeModules($dir: DirectoryID!) {
directory(id: $dir) {
withoutDirectory(path: "node_modules") {
id
}
}
}
Secret handling has been simplified and made more consistent with Directory handling.
type Environment { secret }type Directory { secret }The Container type proposes an expansive definition of the container, similar to the Buildkit/Dockerfile model. A Container is:
This is similar to how buildkit models llb state, and how the Dockerfile language models stage state. Note that Dagger extends this model to include even mount configuration (which are scoped to exec in buildkit, but scoped to container in dagger).
Examples:
"""
Download a file over HTTP in a very convoluted way:
1. Download a base linux container
2. Install curl
3. Download the file into the container
4. Load and return the file
"""
query convolutedDownload($url: String!) {
container {
from(address: "index.docker.io/alpine:latest") {
exec(args: ["apk", "add", "curl"]) {
exec(args: ["curl", "-o", "/tmp/download", $url) {
file(path: "/tmp/download") {
id
}
}
}
}
}
"""
Specialize two containers from a common base
"""
query twoContainers {
container {
from(address: "alpine") {
debug: withVariable(name: "DEBUG", value: "1") {
id
exec(args: ["env"]) {
stdout
}
}
noDebug: withVariable(name: "DEBUG", value: "0") {
id
exec(args: ["env"]) {
stdout
}
}
}
}
}