apollographql / embeddable-explorer

MIT License
35 stars 12 forks source link

Can't disable polling for schema updates #257

Closed thomaswr closed 5 months ago

thomaswr commented 1 year ago

I'm using embedded sandbox and want to disable the polling for schema updates.

This is my HTML document:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body style="height:100vh;margin:0px;overflow:hidden">
  <script src="https://embeddable-sandbox.cdn.apollographql.com/_latest/embeddable-sandbox.umd.production.min.js"></script>
  <script>
    new window.EmbeddedSandbox({
      target: 'body',
      initialEndpoint: 'https://mygqlendpoint.example',
      includeCookies: false,
      initialState: {
        pollForSchemaUpdates: false
      },
      runTelemetry: false
    });
  </script>
</body>
</html>

I still get IntrospectionQuery requests on an interval. Is there an issue with my code?

james-s-w-clark commented 6 months ago

I notice the same too.

The GQL endpoints I want to hit need a token, so polling by default means we'll send a bunch of unauthorized requests before the user has entered the token to be sent.

Looking at EmbeddedSandbox.ts, I think your example is correct.

mayakoneval commented 5 months ago

Hello, thanks for the report. The way we have this working is that if you ever have changed the poll setting on Sandbox (either by clicking the red or green dot next to the endpoint input, or by going to the connection settings), we just go off of your last selection. If you turn off polling once, it should persist across sessions.

Let me know if this works for you. Thank you!

james-s-w-clark commented 5 months ago

Hi @mayakoneval , that would be fine for us if we could set the default poll setting to manual (rather than auto refresh), or disable polling.

The problem for us is that we need to add authentication to make the requests valid, and without the auth our servers will report loads of unauthorized requests with these defaults.

We would have a simpler UX (no need to manually change the poll setting) and less unauthorised requests if we could set the default polling behaviour (or just disable polling).