Skip to main content
View as Markdown

Queries CLI Commands

Manage queries in your EventCatalog from the command line.

getQuery

Returns a query from EventCatalog by its ID

Arguments:

NameTypeRequiredDescription
idstringYesThe ID of the query to retrieve
versionstringNoSpecific version to retrieve

Examples:

# Get the latest query
npx @eventcatalog/cli getQuery "GetOrder"

# Get a specific version
npx @eventcatalog/cli getQuery "GetOrder" "1.0.0"

getQueries

Returns all queries from EventCatalog

Arguments:

NameTypeRequiredDescription
optionsjsonNoOptions: {latestOnly?, attachSchema?}

Examples:

# Get all queries
npx @eventcatalog/cli getQueries

writeQuery

Writes a query to EventCatalog

Arguments:

NameTypeRequiredDescription
queryjsonYesQuery object with id, name, version, and markdown
optionsjsonNoOptions: {path?, override?, versionExistingContent?}

writeQueryToService

Writes a query to a specific service

Arguments:

NameTypeRequiredDescription
queryjsonYesQuery object
servicejsonYesService reference: {id, version?}
optionsjsonNoOptions: {path?, format?, override?}

rmQuery

Removes a query by its path

Arguments:

NameTypeRequiredDescription
pathstringYesPath to the query

Examples:

# Remove a query
npx @eventcatalog/cli rmQuery "/GetOrder"

rmQueryById

Removes a query by its ID

Arguments:

NameTypeRequiredDescription
idstringYesThe ID of the query to remove
versionstringNoSpecific version to remove

Examples:

# Remove a query
npx @eventcatalog/cli rmQueryById "GetOrder"

versionQuery

Moves the current query to a versioned directory

Arguments:

NameTypeRequiredDescription
idstringYesThe ID of the query to version

Examples:

# Version a query
npx @eventcatalog/cli versionQuery "GetOrder"

addFileToQuery

Adds a file to a query

Arguments:

NameTypeRequiredDescription
idstringYesThe ID of the query
filejsonYesFile object: {content, fileName}
versionstringNoSpecific version

addSchemaToQuery

Adds a schema to a query

Arguments:

NameTypeRequiredDescription
idstringYesThe ID of the query
schemajsonYesSchema object: {schema, fileName}
versionstringNoSpecific version

queryHasVersion

Checks if a specific version of a query exists

Arguments:

NameTypeRequiredDescription
idstringYesThe ID of the query
versionstringYesVersion to check

Examples:

# Check if version exists
npx @eventcatalog/cli queryHasVersion "GetOrder" "1.0.0"