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

fix: using await in the html file for the hapi middleware #381

Merged
merged 2 commits into from
Feb 9, 2024

Conversation

Rowadz
Copy link
Contributor

@Rowadz Rowadz commented Jan 8, 2024

Hello, thank you for this project it's impressive :)

Tried to use it out of curiosity and I noticed an issue with the HTML file that gets generated from src/middleware/render-voyager-page.ts.

The issue is that it's using await which breaks the browser:

Screenshot 2024-01-08 at 20 58 45 Screenshot 2024-01-08 at 20 58 56

We shouldn't be using await, so I changed the file to include this:

window.addEventListener('load', async function (event) {
  fetch('${endpointUrl}', {
    method: 'post',
    headers: Object.assign(
      {},
      {
        Accept: 'application/json',
        'Content-Type': 'application/json',
      },
      `${headersJS}`
    ),
    body: JSON.stringify({
      query: GraphQLVoyager.voyagerIntrospectionQuery,
    }),
    credentials: 'include',
  })
    .then((response) => response.json())
    .then((introspection) => {
      GraphQLVoyager.renderVoyager(document.getElementById('voyager'), {
        introspection,
        displayOptions: `${JSON.stringify(displayOptions)}`,
      })
    })
})

I tested this locally with Hapi, following this

Thanks!

@Rowadz
Copy link
Contributor Author

Rowadz commented Jan 8, 2024

Something that might be interesting is that when running npm run compile:middleware, the complied middleware doesn't match what's being installed in version 2.0.0, only one await is being used.

@Rowadz Rowadz changed the title remove using await in the html file fix: using await in the html file for the hapi middleware Jan 8, 2024
@LongLiveCHIEF
Copy link

related #372 and #375

@LunaticMuch LunaticMuch self-requested a review January 24, 2024 20:37
@LunaticMuch LunaticMuch added the PR: bug fix 🐞 requires increase of "patch" version number label Jan 24, 2024
@LunaticMuch LunaticMuch self-requested a review February 9, 2024 08:33
@LunaticMuch LunaticMuch merged commit ae28413 into graphql-kit:main Feb 9, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: bug fix 🐞 requires increase of "patch" version number
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants