Skip to content
Advertisement

Problems accessing data from a GraphQL query in Javascript with Svelte

Below I have my working function using a normal REST response that I want to try to convert into a GraphQL version, it fetches a JSON doc from my Phoenix Server and stores the object values from the JSON doc into an object. The problem is, here I can use await and then assign the new object values from the object within the JSON document, but using GraphQL I cannot access this data to assign it because there is no await function as its just a Query. (From what I know)

JavaScript

Ultimately I am asking if there is a way to access and assign data from a GraphQL query in JavaScript so I can manipulate it before displaying it in my frontend Svelte app.

Example of current GraphQL query:

JavaScript

Advertisement

Answer

I have found a working solution with the help of @Thomas-Hennes

JavaScript

await didn’t like being assigned to a variable or having its data manipulated so i used it as a promise instead and manipulated the response. The below link helped me find the final piece of the puzzle. https://docs.realm.io/sync/graphql-web-access/using-the-graphql-client

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement