Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

query promise not being returned #122

Open
shorif2000 opened this issue Apr 16, 2022 · 0 comments
Open

query promise not being returned #122

shorif2000 opened this issue Apr 16, 2022 · 0 comments

Comments

@shorif2000
Copy link

shorif2000 commented Apr 16, 2022

I have tried both these examples but they did not work.

https://stackoverflow.com/questions/66496332/problems-accessing-data-from-a-graphql-query-in-javascript-with-svelte

I created my own Promise


let companyStore;
  async function getCompany() {
  companyStore = query("xyz");
  (await $companyStore);
  return new Promise(async (resolve, reject)  => {
    console.log("inside promise")
    if ($companyStore.data?.error){
          reject($companyStore.data?.error)
        }
    console.log($companyStore.data?.queryData)
      while($companyStore.data == undefined) {
        if ($companyStore.data?.error){
          reject($companyStore.data?.error)
        }
        console.log("await", $companyStore.data)
        await delay(1000);
      }

      console.log($companyStore.data?.queryData)
        resolve($companyStore.data?.queryData)
  })
  
  };

Can there be support for Promise on a query with example on how to use

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant