|
| 1 | +--- |
| 2 | +'@graphql-hive/core': minor |
| 3 | +'@graphql-hive/apollo': minor |
| 4 | +'@graphql-hive/envelop': minor |
| 5 | +'@graphql-hive/yoga': minor |
| 6 | +--- |
| 7 | + |
| 8 | +Add support for providing a logger object via `HivePluginOptions`. |
| 9 | + |
| 10 | +It is possible to provide the following options: |
| 11 | + |
| 12 | +- **'trace'** |
| 13 | +- **'debug'** |
| 14 | +- **'info'** default |
| 15 | +- **'warn'** |
| 16 | +- **'error'** |
| 17 | + |
| 18 | +```ts |
| 19 | +import { createHive } from '@graphql-hive/core' |
| 20 | + |
| 21 | +const client = createHive({ |
| 22 | + logger: 'info' |
| 23 | +}) |
| 24 | +``` |
| 25 | + |
| 26 | +In addition to that, it is also possible to provide a Hive Logger instance, that allows more control over how you want to log and forward logs. |
| 27 | + |
| 28 | +```ts |
| 29 | +import { createHive } from '@graphql-hive/core' |
| 30 | +import { Logger } from '@graphql-hive/logger' |
| 31 | + |
| 32 | +const client = createHive({ |
| 33 | + logger: new Logger() |
| 34 | +}) |
| 35 | +``` |
| 36 | + |
| 37 | +Head to our [Hive Logger documentation](https://the-guild.dev/graphql/hive/docs/logger) to learn more. |
| 38 | + |
| 39 | +___ |
| 40 | + |
| 41 | +**The `HivePluginOptions.debug` option is now deprecated.** Instead, please use the `logger` option to control logging levels. |
| 42 | + |
| 43 | +```diff |
| 44 | + import { createHive } from '@graphql-hive/core' |
| 45 | + |
| 46 | + const client = createHive({ |
| 47 | +- debug: process.env.DEBUG === "1", |
| 48 | ++ logger: process.env.DEBUG === "1" ? "debug" : "info", |
| 49 | + }) |
| 50 | +``` |
| 51 | + |
| 52 | +**Note**: If the `logger` property is provided, the `debug` option is ignored. |
| 53 | + |
| 54 | +___ |
| 55 | + |
| 56 | +**The `HivePluginOptions.agent.logger` option is now deprecated.** Instead, please provide |
| 57 | +`HivePluginOptions.logger`. |
| 58 | + |
| 59 | +```diff |
| 60 | + import { createHive } from '@graphql-hive/core' |
| 61 | + |
| 62 | + const logger = new Logger() |
| 63 | + |
| 64 | + const client = createHive({ |
| 65 | + agent: { |
| 66 | +- logger, |
| 67 | + }, |
| 68 | ++ logger, |
| 69 | + }) |
| 70 | +``` |
| 71 | + |
| 72 | +**Note**: If both options are provided, the `agent` option is ignored. |
0 commit comments