Evaluating a value from the string, returned by the API

Hello,

I have an own GraphQL API, that I intend to use for 2 step configuration process: on the first page, user can create a JSON Schema and submit it to an API, on the next page - Retool should use the provided schema to generate the JSON Schema form.

Generally, that idea would work fine, unless I would like to include the data from another query to make the dropdown. To achieve that purpose, I generate the schema that looks like that:

"retoolSchema": "{\n \"title\": \"Example\",\n \"type\": \"object\",\n \"properties\": {\n \"building\": {\n \"$ref\": \"#/definitions/buildings\"\n },\n \"name\": {\n \"type\": \"string\"\n }\n },\n \"definitions\": {\n \"buildings\": {\n \"type\": \"number\",\n \"enum\": {{buildingsQuery.data.buildings.map(x => x.id)}},\n \"enumNames\": {{buildingsQuery.data.buildings.map(x => x.name)}}\n }\n }\n}",
I expected that string to be evaluatable to the valid JSON schema format, but query data doesn't get evaluated. If I copy the value and paste it - evaluation happens.

Is there a way to evaluate the string in a runtime? Or maybe there are some better approaches to that problem?

Hey @skayred, would you mind sharing some screenshots of what your current implementation looks like? Thank You!

Hello, unfortunately, I don't have that page alive anymore :frowning:
Basically, the idea is following - if I type, for example,

{{buildingsQuery.data.buildings[0].name}}

during the editing, I can access the variable and use it further, but if I receive the exactly same string from the backend - it gets rendered as a string and doesn't show the query content.

ahhhh, so if I understand correctly in your Retool App you were able to use the

{{buildingsQuery.data.buildings[0].name}}

syntax, but once the JSON Schema form is generated the code snippet above is sent to your backend as a string?

How exactly were you generating the JSON Schema form? If you have another app that is trying to implement this I would love to take a look and see what we can figure out!