Get Component and Component Version
Key learnings
By the end of this task, you will be able to:
- Use inline fragments to access data from an item (of item type Component).
- Understand the fields associated with the items query, Items object, Item object, and the Component object.
- Fetch the list of components with the help of itemId and projectId.
- Query the content of a component to access the tip componentVersion stored within.
- Mine the component to generate thumbnails of the most recent version of that component.
Queries used in this task
You will use the following queries in this task:
Type | Operation | Description |
---|---|---|
Query | Items | Retrieves all files and folders within a specified folder. |
Step 1 - Request for a list of Components within a Folder
The items query returns Items object, which contains a list of all types of items. To restrict the response to Components, we use the inline fragment on Component
. We retrieve the id
and name
fields of the components.
- In Manufacturing Data Model Explorer, enter the following query in the Query pane:
Query
query GetItems($projectId: String!, $itemId: String!) {
items(projectId: $projectId, itemId: $itemId) {
results {
... on Component {
id
name
}
}
}
}
- In the Query Variables Pane, replace the value of the
projectId
variable with theprojectId
of the project you want to explore. This ID was returned in response to the query in Get Projects. - In the Query Variables Pane, replace the value of the
itemId
variable with theid
of the root folder of the project you want to explore. This ID was returned in response to the query in Get Projects.
Query Variables
{
"projectId": "a.YnVzaW5lc3M6YXV0b2Rlc2s2MTA0I0QyMDIyMDIwMjQ5MjcyNTIzMQ",
"itemId": "urn:adsk.wipprod:fs.folder:co.X97YjKyaStKU9UnADkhk-w"
}
- Click Play. The list of components within the root folder is displayed in the response. Note down the ID of one of the components. You will use need ID for the remaining task. For better understanding, we will use the ID of the component named
Cylinder
to proceed further.
You can then see the responses of the request similar to the response in the following code-block:
Response
{
"data": {
"items": {
"results": [
{},
{},
{},
{},
{},
{
"id": "Y29tcH5jby5uckdoR0ZIb1FXU3NQdFlhU0V2YThnfnlJc0hrT3BuWmpxSVJUZk9jS1Vvb3ZfYWdh",
"name": "ECO Data Test"
},
{
"id": "Y29tcH5jby5uckdoR0ZIb1FXU3NQdFlhU0V2YThnfnhHTFhxNkZIMlk2dDVOdDJPYkxaOVdfYWdh",
"name": "Box"
},
{},
{
"id": "Y29tcH5jby5uckdoR0ZIb1FXU3NQdFlhU0V2YThnfjU5U2hmcnZlMWFacHB4ZUdwSlE2OWhfYWdh",
"name": "Lifecycle Test Data"
},
{},
{
"id": "Y29tcH5jby5uckdoR0ZIb1FXU3NQdFlhU0V2YThnfnZlQW9NUjBiVkQxUGJGZWxSMGFQclFfYWdh",
"name": "Basic Test Data"
},
{
"id": "Y29tcH5jby5uckdoR0ZIb1FXU3NQdFlhU0V2YThnfkxIZVdyeTViTlBscEI1NFZUUk1JQkhfYWdh",
"name": "ME Data Test"
},
{
"id": "Y29tcH5jby5uckdoR0ZIb1FXU3NQdFlhU0V2YThnfkFManNhRnA3TmhKaFk3YlN1QXBTdmxfYWdh",
"name": "X-Carve"
},
{},
{
"id": "Y29tcH5jby5uckdoR0ZIb1FXU3NQdFlhU0V2YThnfkZ0aktjbkVsQWtRSWtRVG5zVHg2OTBfYWdh",
"name": "SubodhBox0429_1"
},
{},
{},
{},
{},
{},
{
"id": "Y29tcH5jby5uckdoR0ZIb1FXU3NQdFlhU0V2YThnfm9GS3FzblVCR3BWVkFDT0t0SlU4OXFfYWdh",
"name": "Snapshot Creation Event Test"
},
{
"id": "Y29tcH5jby5uckdoR0ZIb1FXU3NQdFlhU0V2YThnflUyZ3MyOGp4azMyVWpMSXpid29VTE1fYWdh",
"name": "ISO 4032 - M4ISO"
},
{
"id": "Y29tcH5jby5uckdoR0ZIb1FXU3NQdFlhU0V2YThnfkVvcFQzbE1jM0NuSHZDSjk3Mk02WkRfYWdh",
"name": "Release"
},
{},
{
"id": "Y29tcH5jby5uckdoR0ZIb1FXU3NQdFlhU0V2YThnfmJ5TlFsa1pFSzRXaEtFYUxIVGdQWUZfYWdh",
"name": "Reproduce Bug"
},
{
"id": "Y29tcH5jby5uckdoR0ZIb1FXU3NQdFlhU0V2YThnfjVEcWcwOTQ0U3VjYmJlSjc5SVE5TVVfYWdh",
"name": "Noemie's Box"
},
{},
{
"id": "Y29tcH5jby5uckdoR0ZIb1FXU3NQdFlhU0V2YThnfjI2VFBOb0lxWjhHYjJ4WDRKeTlrbkFfYWdh",
"name": "SubodhTest"
},
{
"id": "Y29tcH5jby5uckdoR0ZIb1FXU3NQdFlhU0V2YThnfmpReFpYa3ROMFF4U1Bwd0xXMTY4OVZfYWdh",
"name": "Puck"
}
]
}
}
}
After working through the steps mentioned above, you should see a screen similar to the following image.
Note: Empty objects “{}” may appear for objects that exist in the folder but are not defined as Components (they may be Folders or Drawings, for example). If you are curious, you can use the __typename
keyword to display the types of those objects. You can see an example of the __typename
keyword used in the following image.

Step 2 - Extract the Component Version within the Component
The item query returns an object representing an Item. To extract the tip component version, which is specific to Components, we use the inline fragment on Component
. Within the Component Version, we request for the thumbnail, which kicks of thumbnail generation.
- In Manufacturing Data Model Explorer, enter the following query in the Query Pane :
Query
query Getltem($projectId: String!, $itemId: String!) { item(projectId: $projectId, itemId: $itemId) { id name ... on Component { tipVersion{ id name thumbnail{ status } } } } }
Show More
- In the Query Variables Pane, replace the value of the
projectId
variable with theprojectId
that you used for previous query in Get Projects. - In the Query Variables Pane, replace the value of the
itemId
with theid
of thecomponent
returned for the previous query in Get Projects.
Query Variables
{ "projectId": "a.YnVzaW5lc3M6YXV0b2Rlc2s2MTA0I0QyMDIyMDIwMjQ5MjcyNTIzMQ", "itemId": "Y29tcH5jby5uckdoR0ZIb1FXU3NQdFlhU0V2YThnfkxIZVdyeTViTlBscEI1NFZUUk1JQkhfYWdh" }
- Click Play. Thumbnail generation begins, and the status of the generating process is returned. The id of the Thumbnail is displayed in the response section.
You should see the responses of the request similar to the response in the following code-block:
Response
{ "data": { "item": { "id": "Y29tcH5jby5uckdoR0ZIb1FXU3NQdFlhU0V2YThnfkxIZVdyeTViTlBscEI1NFZUUk1JQkhfYWdh", "name": "ME Data Test", "tipVersion": { "id": "Y29tcH5jby5uckdoR0ZIb1FXU3NQdFlhU0V2YThnfkxIZVdyeTViTlBscEI1NFZUUk1JQkhfYWdhfkRBNWdhRHpUYU5vYkg4S25ObnlZek4", "name": "ME Data Test", "thumbnail": { "status": "SUCCESS" } } } } }
Show More
After working through the steps mentioned above, you should see a screen similar to the following image.
