Retrieving Attachments
Attachments can be screenshots, photos, and videos created during a session. The links to these assets can be retrieved via GraphQL.
Photos
During various steps of a session, a user might be required to take photos. Photo attachments are associated to the events that happen on a step during the session. In the GraphQL API, photos can retrieved by querying the events on a session.
All Photos from a Session
There are many ways to retrieve the event data, but the following example will look at a common use case for retrieving all the photos from a session with a known session id. The session id can be retrieved prior by looking at a user’s list of scenario sessions or performing queries to find the desired session.
Arguments
These are all optional arguments since the query will return all the events available. In this example, we will filter the results based on the scenario session id and the type of values found on the event.
id: The GraphQL ID of the scenario session
first: How many results in the query. Maximum of 100 results in a query. Use the AfterIndex paramter to obtain more results.
valueTypes: The types of values that events will be filtered. In this example, it will be a
PHOTO
.
Query
The query will return the URL of the photo as fileUrl, and also the name of the step it was captured on:
query FetchScenarioSessionEvents(
$valueTypes: [ScenarioStepItemTypeEnum!],
$first: Int!,
$scenarioSessionId: ID) {
scenarioSessionEvents (first: $first, valueTypes: $valueTypes, scenarioSessionId: $scenarioSessionId){
nodes {
id
type
eventData
photo {
fileUrl
}
scenarioSessionStep {
scenarioStep {
id
name
}
}
}
}
}
Query Variables
Here are the variables to pass in with the query:
{
"scenarioSessionId": "123456789",
"first": 100,
"valueTypes": [PHOTO]
}
Photos on Scenario Session Step
This example returns the photos captured on a particular scenario session step. The query is very similar to the prior example but the event will be filtered through the scenario step query type.
Arguments
These are all optional arguments since the query will return all the events available. In this example, we will filter the results based on the scenario session id and the type of values found on the event.
scenarioSessionId: The GraphQL ID of the scenario session.
scenarioStepId: The GraphQL ID of the scenario step. Note that this is not the scenario session step but the step id itself. The scenario step ID can be retrieved by looking at all the scenario steps within a published scenario and retrieving the ID for the desired step.
firstEvents: How many event results to return in the query. Maximum of 100 results in a query. Use the AfterIndex paramter to obtain more results.
firstSteps: How many step results to return in the query. Maximum of 100 results in a query. Use the AfterIndex paramter to obtain more results.
valueTypes: The types of values that events will be filtered. In this example, it will be a
PHOTO
.
Query
The query will return the URL of the photo as fileUrl, and also the name of the step it was captured on:
query FetchScenarioSessionStepEvents(
$valueTypes: [ScenarioStepItemTypeEnum!],
$firstSteps: Int!
$firstEvents: Int!,
$scenarioSessionId: ID,
$scenarioStepId: ID) {
scenarioSessionSteps(first: $firstSteps, scenarioStepId: $scenarioStepId) {
nodes {
scenarioStep {
id
name
}
scenarioSessionEvents (first: $firstEvents, valueTypes: $valueTypes){
nodes {
id
type
eventData
photo {
fileUrl
}
scenarioSessionStep {
scenarioStep {
id
name
}
}
}
}
}
}
}
Query Variables
Here are the variables to pass in with the query:
Â