The GraphQL API is still evolving and is subject to breaking changes. A large portion of the API is primarily for internal use by Dagit. For any of the queries below, we will be clear about breaking changes in release notes.
The GraphQL API is served alongside the Dagit web server. To start the server, run dagit in your Dagster workspace.
dagit
Dagit serves the GraphQL endpoint at the /graphql endpoint. If you are running Dagit locally on port 3000, you can access the API at localhost:3000/graphql
You can access the GraphQL Playground by navigating to the /graphql route in your browser. The GraphQL Playground contains the full GraphQL Schema and an interactive playground to write and test queries and mutations.
Clicking on the Docs tab on the right edge of the playground opens up interactive documentation for the GraphQL API. The interactive documentation is the best way to explore the API and get information about which fields are available on the queries and mutations.
Given a repository, this query returns the names of all the jobs in the repository.
This query takes a selector, which is of type RepositorySelector. A repository selector consists of both the repository location name and repository name.
query JobsQuery(
$repositoryLocationName: String!
$repositoryName: String!
) {
repositoryOrError(
repositorySelector: {
repositoryLocationName: $repositoryLocationName
repositoryName: $repositoryName
}
) {
... on Repository {
jobs {
name
}
}
}
}
To launch a run, we can use the launchRun mutation. Here, we define LaunchRunMutation to wrap our mutation and allow us to pass in the required arguments as query variables.
For this query, the required arguments are:
selector:
This is a dictionary that contains the repository location name, repository name, and job name
runConfigData:
This is where you define the run config for the job execution.
Note that runConfigData is of type RunConfigData. This type is used when passing in an arbitrary object for run config. This is any-typed in the GraphQL type system but must conform to the constraints of the config schema for this job. If it does not, the mutation returns a RunConfigValidationInvalid response