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

(feat) - offer the option to use this in production #3

Closed JoviDeCroock closed 5 years ago

JoviDeCroock commented 5 years ago

I think this is the correct way to tackle https://github.com/FormidableLabs/urql-devtools/issues/48 now that useDevtoolsContext is integrated into this library. A user is actively encouraged to do the following:

const client = createClient({
  exchanges: [
    process.env.NODE_ENV !== 'production' && devToolsExchange,
    ...rest
  ].filter(Boolean)
})

If the consumer of the application doens't want it enabled in production it won't be and the bundle size won't be affected since terser will eliminate the code.

andyrichardson commented 5 years ago

Thanks for this one! Happy to merge this but I'll put on hold until I add something to the README.

How do you feel about urql exposing a conditional exchange function?

[dedupExchange, conditionalExchange(devtoolsExhcange, true), otherExchange]
JoviDeCroock commented 5 years ago

The problem I see forming is the nested conditions for this. Normally terser and stuff should be able to handle this but yes, not entirely sure if all minifiers can.