urql-graphql / urql-devtools-exchange

The exchange for usage with Urql Devtools
https://www.npmjs.com/package/@urql/devtools
MIT License
54 stars 6 forks source link

Option to force on in production #118

Open adam-thomas-privitar opened 2 years ago

adam-thomas-privitar commented 2 years ago

Currently, there is no way to force the exchange to work in production. This can be useful when you want to analyse things in production. This has actually been previously discussed on a ticket i created a while ago (on the wrong repo, whoops): https://github.com/FormidableLabs/urql-devtools/issues/48.

It was kindly fixed by @JoviDeCroock.

Since then though it looks like the guard on NODE_ENV has returned and theres no way to override it.

It'd probably be annoying for folks to just remove the guard because people might see it unexpectedly start being there in prod (which might be why it came back?), so I understand this is actually not that trivial to fix without major version bump.

Maybe the exchange could have a new init function attached to it which accepts a config object or something?

createClient({
  exchanges: [
    devToolsExchange.init({force: true})
  ]
})

That way you could still use the current behaviour like

createClient({
  exchanges: [
    devToolsExchange
  ]
})

Without changing it for anyone. Alternatively there could be another env var introduced to override.