Skip to main content

Stash GraphQL API

Alpha

This feature is alpha. Names, fields, and behavior can change or be removed at any time without notice.

The stash operations are in the V2 GraphQL API. Their names start with alpha. For authentication, see Authentication.

Each operation names a stash with a scope. Set exactly one field of the scope: project, environment, component, instance, or deployment. A deployment is its UUID. The others are identifiers, such as billing-dev-app.

alphaStashEntry​

Gets one entry. Expired entries are not returned. You need stash:view. A sensitive value is null unless you have stash:export.

graphql
query {
alphaStashEntry(organizationId: "my-org", scope: { instance: "billing-dev-app" }, key: "schema.version") {
key
value
label
expiresAt
}
}

alphaStashEntries​

Lists the entries in one stash, ordered by key. You need stash:view. Sensitive values are null unless you have stash:export.

graphql
query {
alphaStashEntries(organizationId: "my-org", scope: { environment: "billing-dev" }) {
items { key value format }
cursor { next }
}
}

alphaStashEntriesForScopes​

Lists the entries in up to 200 stashes in one project. You need stash:view on every scope. Sensitive entries are never returned. The filter.keys argument returns only the keys that you name.

graphql
query {
alphaStashEntriesForScopes(
organizationId: "my-org"
scopes: [{ project: "billing" }, { environment: "billing-dev" }, { instance: "billing-dev-app" }]
filter: { keys: ["owner"] }
) {
items {
scope { kind id }
key
value
}
cursor { next }
}
}

alphaSetStashEntry​

Sets a key. You need stash:write. The input replaces the whole entry. A deployment's own token can set keys on that deployment and on its instance, environment, component, and project. The mutation fails when the key has an immutable entry that has not expired, or when the stash has its maximum number of keys.

graphql
mutation {
alphaSetStashEntry(
organizationId: "my-org"
scope: { instance: "billing-dev-app" }
key: "schema.version"
input: { value: "42", label: "Schema version", ttl: 86400 }
) {
successful
result { key value expiresAt }
messages { field message }
}
}

The input fields are value, format, label, ttl, immutable, and sensitive. Only value is required.

alphaDeleteStashEntry​

Deletes a key. You need stash:write. Immutable entries can be deleted. The result has the deleted entry. Its value is null when the entry is sensitive.

graphql
mutation {
alphaDeleteStashEntry(organizationId: "my-org", scope: { project: "billing" }, key: "release") {
successful
result { key }
}
}

alphaStashEvents​

A subscription to entries that are set or deleted in a project. You need stash:view on the project, and on the environment when you pass environmentId. An event's entry is null when you do not have stash:view on the entity that holds it. Without environmentId, you get events for the project, its environments, and its components. With environmentId, you also get events for that environment's instances and their deployments.

The action is SET or DELETED. A sensitive value is always null in an event. An entry that expires sends no event.

graphql
subscription {
alphaStashEvents(organizationId: "my-org", projectId: "billing", environmentId: "billing-dev") {
action
scope { kind id }
key
entry { value expiresAt }
timestamp
}
}

alphaWidgetCatalog​

Lists every version of every widget, with its well-known key, the version, the kind of entity that holds the key, the format, the JSON Schema, and the inputs.

graphql
query {
alphaWidgetCatalog {
name
entity
key
keySegments
segmentValues
version
scope
format
schema
inputs { name type required field }
}
}

keySegments names the segments in a pattern key, such as ["step"] for md/v1/step/{step}. segmentValues lists, by segment name, the only values that a segment can have. A segment that is not in segmentValues can be any value that follows the segment rule.

alphaWidgetsForScopes​

Lists the widgets of up to 200 stashes in one project. You need stash:view on every scope. It returns a widget for each well-known key that has a valid value. When a stash has more than one version of a key, it uses the highest version. An instance scope also returns the deployment results of the instance's latest deployment that has a well-known key. The scope of each of those widgets is that deployment, and rolledUpTo is the instance. rolledUpTo is null for every other widget. A page can have fewer widgets than its limit, or none. Read pages until cursor.next is null.

graphql
query {
alphaWidgetsForScopes(
organizationId: "my-org"
scopes: [{ environment: "billing-dev" }, { instance: "billing-dev-app" }]
) {
items {
name
scope { kind id }
rolledUpTo { kind id }
segments
values
expiresAt
}
cursor { next }
}
}

values has the widget's inputs by name, for example {"value": 37, "max": 100}. segments has the values of the key's named segments, for example {"step": "src"} for md/v1/step/src.

alphaUiNotices​

A query and a subscription for the UI notices that you can see in your organization. A notice is an md/v1/ui-ephemeral-notice entry that Massdriver sets when a project or environment is created, and on an environment when one of its deployments is proposed, approved, started, or completed. You see the notices of the projects and environments where you have stash:view.

The query lists the notices, newest first. Expired notices are not returned. Read it when a page opens.

graphql
query {
alphaUiNotices(organizationId: "my-org") {
items {
scope { kind id }
data
expiresAt
}
cursor { next }
}
}

The subscription sends each new notice. One subscription covers every project and environment where you have stash:view, including the ones that are created after you subscribe. An expiry sends no event, so drop a notice when its expiresAt passes.

graphql
subscription {
alphaUiNotices(organizationId: "my-org") {
scope { kind id }
data
expiresAt
}
}