|
| 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 | +- **`'error'`** log errors |
| 13 | +- **`'info'`** log errors and informal logs |
| 14 | +- **`'debug'`** log errors, informal and debug logs |
| 15 | + |
| 16 | +```ts |
| 17 | +import { createHive } from '@graphql-hive/core' |
| 18 | + |
| 19 | +const client = createHive({ |
| 20 | + logger: 'info' |
| 21 | +}) |
| 22 | +``` |
| 23 | + |
| 24 | +In addition to that, it is also possible to provide a error logging instance, where you can |
| 25 | +customize how logs are forwarded. |
| 26 | + |
| 27 | +```ts |
| 28 | +import { createHive } from '@graphql-hive/core' |
| 29 | + |
| 30 | +const client = createHive({ |
| 31 | + logger: { |
| 32 | + info() {}, |
| 33 | + error() {}, |
| 34 | + debug() {} |
| 35 | + } |
| 36 | +}) |
| 37 | +``` |
| 38 | + |
| 39 | +Deprecates the `HivePluginOptions.debug` option. Instead, please provide a logger with a `debug` |
| 40 | +method. |
| 41 | + |
| 42 | +```diff |
| 43 | + import { createHive } from '@graphql-hive/core' |
| 44 | + |
| 45 | + const client = createHive({ |
| 46 | +- debug: process.env.DEBUG === "1", |
| 47 | ++ logger: process.env.DEBUG === "1" ? "debug" : "info", |
| 48 | + }) |
| 49 | +``` |
| 50 | + |
| 51 | +Deprecate the `HivePluginOptions.agent.logger` option. Instead, please provide |
| 52 | +`HivePluginOptions.logger`. |
| 53 | + |
| 54 | +```diff |
| 55 | + import { createHive } from '@graphql-hive/core' |
| 56 | + |
| 57 | + const logger = { |
| 58 | + info() {}, |
| 59 | + error() {}, |
| 60 | + debug() {}, |
| 61 | + }; |
| 62 | + |
| 63 | + const client = createHive({ |
| 64 | + agent: { |
| 65 | +- logger, |
| 66 | + }, |
| 67 | ++ logger, |
| 68 | + }) |
| 69 | +``` |
0 commit comments