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 where the session id is known. The session id can be retrieved prior by looking at a user’s list of scenario sessions.
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 due to request size.
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.
firstEvents: How many event results in the query. Maximum of 100 due to request size.
firstSteps: How many steps results in the query. It is expected to only be one.
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:
{ "scenarioSessionId": "123456789", "scenarioStepId": "09876543", "firstSteps": 10, "firstEvents": 100, "valueTypes": [PHOTO] }
Add Comment