The Configuration Management Toolkit Cloud now supports GraphQL, allowing you to interact with bundles more efficiently. This guide will walk you through the process of using GraphQL to perform various operations related to bundles. Firstly you should get your webtrigger with command:
forge webtrigger
After obtaining your web trigger URL, you can send requests with an Authorization header, which you obtain from the API Tokens page.
Fetching Bundle Information:
To retrieve detailed information about a specific bundle, you can use the getBundle
operation. Provide the bundle ID as a parameter to fetch its details, including its name, project ID, start date, release date, version ID, archived status, and the list of child component versions.
GraphQL Query:
{ "query": "{ getBundle(id: \"bundle-10001-13td6df2-ab1e-4a91-917b-c25003c9ed13\") { ok errorMessages result { name projectId startDate releaseDate versionId archived children { componentVersionId } released } } } " }
2 . Fetching Bundles by Project ID:
If you want to retrieve all bundles within a specific project, you can use the getBundles
operation. Provide the project ID as a parameter to fetch the list of bundles along with their details.
GraphQL Query:
getAllBundles -> { "query": "{ getBundles(id: \"10001\") { ok errorMessages result { key value { name projectId startDate releaseDate versionId archived children { componentVersionId } released } } } } " }
Saving a Bundle:
To save a bundle, use the saveBundle
mutation. Specify the required fields such as name, project ID, start date, release date, version ID, archived status, list of child component versions, and release status.
GraphQL Mutation:
saveBundle -> { "query": "mutation { saveBundle(newBundle: { name: \"Example Bundle\", projectId: \"10001\", startDate: \"2023-01-01\", releaseDate: \"2024-01-01\", versionId: \"10001\", archived: false, children: [{ componentVersionId: \"componentVersion-10058-10001-10001\" }], released: true } ) { ok errorMessages result { name projectId startDate releaseDate versionId archived children { componentVersionId } released } } }" }
4. Add Component Version To Bundle:
This GraphQL mutation is used to add a new component version to a specific bundle. It includes parameters such as bundle information and the identifier of the new component version to be added. When the operation is successful, the results are returned, including the relevant fields.
GraphQL Mutation:
mutation { addComponentVersionToBundle(bundle: { id: "bundle-10001-2710a2d4-92gd-4d01-9594-fafa852fe468", name: "Example Bundle", projectId: "10001", startDate: "2000-01-01", releaseDate: "2000-01-01", versionId: "10001", archived: false, children: [{ componentId: "10001", versionId: "10001", projectId: "10001" }], released: true }, newComponentVersionId: "componentVersion-10001-10001-10001" ) { ok errorMessages result { name projectId startDate releaseDate versionId archived children { componentVersionId } released } } }
Delete a Bundle:
This GraphQL mutation is used to delete a bundle with the specified ID. When executed, it will return whether the operation was successful (ok
), any error messages (errorMessages
), and the result of the deletion (result
).
mutation { deleteBundle(id: "bundle-10001-0cc217a7-3560-4ec8-a810-6a228228abfb") { ok errorMessages result } }
Delete a Component Verson From a Bundle
This GraphQL mutation is used to remove a specific component version from a bundle. It requires the ID of the bundle (bundleId
) and the ID of the component version (componentVersionId
). When executed, it will return whether the operation was successful (ok
), any error messages (errorMessages
), and the result of the deletion (result
).
mutation { deleteCVFromBundle(bundleId: "bundle-10001-fdb5017d-9142-4rd8-a7c1-e96d73df4dd8", componentVersionId: "componentVersion-10001-10001-10001") { ok errorMessages result } }
Here is the GraphQL query for retrieving bundles within a specified date range:
Fetch Bundles within the Specified Date Range
This GraphQL query retrieves bundles within the specified date range for a particular project. It includes parameters such as the project ID (projectId
), start date (startDate
), and end date (endDate
). When executed, it returns whether the operation was successful (ok
), any error messages (errorMessages
), and the list of bundles within the date range (result
).
{ getBundlesWithinDateRange( projectId: "10001", startDate: "01-01-2023", endDate: "01-01-2024" ) { ok errorMessages result { key value { name projectId startDate releaseDate versionId archived children { componentVersionId } released } } } }