Skip to main content

Environment object schema

The environment object allows you to query information about a particular model based on environmentId.

The Example queries illustrate a few fields you can query with this environment object. Refer to Fields to view the entire schema, which provides all possible fields you can query.

Arguments

When querying for environment, you can use the following arguments.

FieldTypeRequired?Description
idBigInt!YesThe environment id for this model
userIdBigIntNoUserId for a development environment

Example queries

You can use your production environment's id:

query Example {
environment(id: 834){ # Get the latest state of the production environment
applied { # The state of an executed node as it exists as an object in the database
models(first: 100){ # Pagination to ensure manageable response for large projects
edges { node {
uniqueId, name, description, rawCode, compiledCode, # Basic properties
database, schema, alias, # Table/view identifier (can also filter by)
executionInfo {executeCompletedAt, executionTime}, # Metadata from when the model was built
tests {name, executionInfo{lastRunStatus, lastRunError}}, # Latest test results
catalog {columns {name, description, type}, stats {label, value}}, # Catalog info
ancestors(types:[Source]) {name, ...on SourceAppliedStateNode {freshness{maxLoadedAt, freshnessStatus}}}, # Source freshness }
children {name, resourceType}}} # Immediate dependencies in lineage
totalCount } # Number of models in the project
}
definition { # The logical state of a given project node given its most recent manifest generated
models(first: 100, filter:{access:public}){ # Filter on model access (or other properties)
edges { node {
rawCode, # Compare to see if/how the model has changed since the last build
jobDefinitionId, runGeneratedAt, # When the code was last compiled or run
contractEnforced, group, version}}} # Model governance
}
}

With the deprecation of the data type Int for id, below is an example of replacing it with BigInt:

query ($environmentId: BigInt!, $first: Int!) {
environment(id: $environmentId) {
applied {
models(first: $first) {
edges {
node {
uniqueId
executionInfo {
lastRunId
}
}
}
}
}
}
}

With the deprecation of modelByEnvironment, below is an example of replacing it with environment:

query ($environmentId: BigInt!, $uniqueId: String) {
environment(id: $environmentId) {
applied {
modelHistoricalRuns(uniqueId: $uniqueId) {
uniqueId
executionTime
executeCompletedAt
}
}
}
}

Fields

When querying an environment, you can use the following fields.

FieldTypeDescription
adapterTypeStringThe adapter type (data platform) that this environment executed with
appliedAppliedState
consumerProjects[ConsumerProject!]!Projects that depend on the current environment
dbtProjectNameStringThe project name for this environment
definitionDefinitionState
modelQueryHistoryStateModelQueryHistoryState!State of model query history for the environment
producerProjects[ProducerProject!]!Projects depended on by the current environment
searchResultsEnvironmentSearchResults_Connection!The results of the query.
selectorAutocomplete[AutocompleteResult!]!

When querying the applied field of environment, you can use the following fields.

FieldTypeDescription
exposureTileExposureTileNodeAn exposure tile in this environment
exposuresExposureAppliedStateNodeConnection!
lastUpdatedAtDateTimeThe timestamp when the environment was last updated, which is when the run was ingested.
latestGitShaStringThe git sha of the project when the applied state was last updated.
latestIssuesAppliedStateLatestIssuesConnection!The most recent issues found in the environment
lineage[!]!Project Lineage.
modelHistoricalRuns[ModelNode!]!Retrieve model information based on environmentId. This will include any run from any job in the specified environment.
modelsModelAppliedStateNodeConnection!
owners[ExposureOwner!]!
packages[String!]!List of packages used in the environment
recentResourceChangesAppliedStateRecentResourceChangesConnection!The most recent changes to resources in the environment, bucketed by day
resourceCountsJSONObjectThe project name for this environment
resourcesEnvironmentAppliedNodeConnection!The paginated results of resources.
searchResultsAppliedStateSearchResults_Connection!The results of the query.
seedsSeedAppliedStateNodeConnection!
snapshotsSnapshotAppliedStateNodeConnection!
sourcesSourceAppliedStateNodeConnection!
tags[Tag!]!The distinct tags of applied resources in the environment
testsTestAppliedStateNodeConnection!The definition state of a test
typeaheadAppliedStateTypeaheadConnection
veSearchAppliedStateVeSearchConnection

When querying the definition field of environment, you can use the following fields.

FieldTypeDescription
exposuresExposureDefinitionNodeConnection!The paginated results of Exposures.
groupsGroupNodeConnection!Groups for model governance.
lastUpdatedAtDateTimeThe timestamp when the environment was last updated, which is when the run was ingested.
lineage[!]!Project Lineage.
macrosMacroDefinitionNodeConnection!
metricsMetricDefinitionNodeConnection!
modelsModelDefinitionNodeConnection!
packages[String!]!List of packages used in the environment
resourceCountsJSONObjectThe project name for this environment
resourcesEnvironmentDefinitionNodeConnection!The paginated results of resources.
savedQueriesSavedQueryDefinitionNodeConnection!
seedsSeedDefinitionNodeConnection!
semanticModelsSemanticModelDefinitionNodeConnection!
snapshotsSnapshotDefinitionNodeConnection!
sourcesSourceDefinitionNodeConnection!
tags[Tag!]!The distinct tags of definition resources in the environment
testsTestDefinitionNodeConnection!
0