Graphql-playground: React - Is not possible to set custom settings in Playground component

Created on 11 Jun 2019  路  8Comments  路  Source: graphql/graphql-playground

I'm trying to use this:

<Playground
          headers={headers}
          endpoint="/graphql"
          height="100%"
          settings={{
            'schema.polling.enable': false
          }}
        />

But the Playground still displaying 'schema.polling.enable' as true.

bu2-confirmed kinbug

Most helpful comment

Here's a programmatic workaround that works for me. It's unfortunate we have to do it this way, but it works:

  import {
    getSettings,
    setSettingsString,
    store,
  } from "graphql-playground-react";

  // grab the redux store
  const state = store.getState();

  // get the current settings
  const settings = getSettings(state);

  // override defaults
  settings["request.credentials"] = "include";

  // dispatch settings string
  store.dispatch(setSettingsString(JSON.stringify(settings, null, 2)));

All 8 comments

Thank you for reporting! I confirmed that settings other than schema.polling.enable are also ignored.

Thanks for the reply @yoshiakis

@yoshiakis is there a way to workaround this?

@douglasmuraoka You can open settings tab by clicking the gear icon at the top right in the PlayGround App :)

I mean, to programmatically provide a custom settings when using the Playground component, or even have an initial store state and dispatch an action manually to set the settings.

@douglasmuraoka I can't think of any work around to do that.

Here's a programmatic workaround that works for me. It's unfortunate we have to do it this way, but it works:

  import {
    getSettings,
    setSettingsString,
    store,
  } from "graphql-playground-react";

  // grab the redux store
  const state = store.getState();

  // get the current settings
  const settings = getSettings(state);

  // override defaults
  settings["request.credentials"] = "include";

  // dispatch settings string
  store.dispatch(setSettingsString(JSON.stringify(settings, null, 2)));

This is a pretty significant limitation. Any chance of this receiving attention? Anyone know what the root issue is?

Was this page helpful?
0 / 5 - 0 ratings