Queries
Get the form definition of a given form
This query allows us to fetch the details and questions for a specific form and can be used to render the form and its questions in your UI.
A form may have questions that are conditionally shown/hidden based on previous answers in the form, which can be referred to as question visibility logic. In order to ensure you're always showing the right set of questions, you have 2 options:
rule
field.evaluateFormRules
mutation and just send us the intermediary responses on the questions and we'll let you know what questions need to be shown/hidden. Click here for more information on this mutation.Form and question metadata is returned in all form queries as a JSON string rather than a JSON object. This is because the metadata is defined in Studio as a JSON string and we want to avoid any potential parsing errors. You can parse the metadata string into a JSON object in your application (for example, using JSON.parse
in JavaScript/TypeScript, json.loads
in Python or json_decode
in PHP or Ruby).
- graphql
01query GetForm($id: String!) {02 form(id: $id) {03 form {04 id05 definition_id # static id from Studio06 title07 key # form key set in Studio08 metadata # JSON metadata string set in Studio09 questions {10 id11 definition_id # static id from Studio12 title # string or html string (for description questions)13 key # question key set in Studio14 dataPointValueType15 questionType16 metadata # JSON metadata string set in Studio17 options {18 id19 value20 label21 }22 rule {23 # visibility conditions of a question24 boolean_operator25 conditions {26 id27 reference # definition id of the question this condition is based on28 operator29 operand {30 type31 value32 }33 }34 }35 }36 }37 }38}
- json
01{02 "id": "{{FORM_ID}}"03}
The id of the form can be found in the object.id
field of an activity.
- json
01{02 "activity": {03 "id": "{{ACTIVITY_ID}}",04 "object": {05 "id": "{{FORM_ID}}",06 "type": "form"07 },08 ...09 }10}