Skip to main content

Function: getQuery()

getQuery(directory): (id, version?, options?) => Promise<Query>

Defined in: queries.ts:37

Returns a query from EventCatalog.

You can optionally specify a version to get a specific version of the query

Parameters

ParameterType
directorystring

Returns

Function

Parameters

ParameterType
idstring
version?string
options?{ attachSchema: boolean; }
options.attachSchema?boolean

Returns

Promise<Query>

Example

import utils from '@eventcatalog/utils';

const { getQuery } = utils('/path/to/eventcatalog');

// Gets the latest version of the event
const event = await getQuery('GetOrder');

// Gets a version of the event
const event = await getQuery('GetOrder', '0.0.1');

// Gets the query with the schema attached
const event = await getQuery('GetOrder', '0.0.1', { attachSchema: true });